Kanzi 3.9.10
kanzi::Node2D Class Reference

Node2D is the base class of 2D nodes. More...

#include <kanzi/core.ui/node/node2d.hpp>

Inheritance diagram for kanzi::Node2D:
[legend]

Classes

struct  ClippingArea
 Clipping information carried from parents. More...
 

Public Types

typedef ChildContainer::const_iterator ChildConstIterator
 Iterator type for children.
 
typedef ChildContainer::const_reverse_iterator ChildConstReverseIterator
 Reverse iterator type for children.
 
typedef vector< Node2DSharedPtrChildContainer
 Container type for children.
 
enum  ForegroundHint { ForegroundHintNone , ForegroundHintTranslucent , ForegroundHintOpaque }
 Hint for foreground handling of nodes. More...
 
typedef NodeSharedPtr(* HitTestVisitor) (Node2D &node, Vector2 nodePoint, void *userData)
 Hit test visitor function.
 
typedef Matrix3x3 LayoutMatrixType
 
typedef Vector2 LayoutVectorType
 
enum  PerspectiveTransformationMode { Screen , XFov , YFov }
 Node2D perspective transformation mode. More...
 
enum  PixelFormat { PixelFormatRgb , PixelFormatRgba }
 Pixel formats. More...
 
enum  RenderType { RenderTypeNone , RenderTypeTexture , RenderTypeManual , RenderTypeManualClipped }
 Node2D render type - affects elementary decisions about node rendering. More...
 
- Public Types inherited from kanzi::Node
enum  ContentStretch {
  ContentStretchNone , ContentStretchFill , ContentStretchUniform , ContentStretchUniformToFill ,
  ContentStretchRepeat
}
 Content stretch option. More...
 
enum  DepthAlignment { DepthAlignmentBack , DepthAlignmentFront , DepthAlignmentCenter , DepthAlignmentStretch }
 Depth alignment options. More...
 
enum  HorizontalAlignment { HorizontalAlignmentLeft , HorizontalAlignmentRight , HorizontalAlignmentCenter , HorizontalAlignmentStretch }
 Horizontal alignment options. More...
 
typedef InputManipulatorContainer::const_iterator InputManipulatorConstIterator
 
typedef vector< InputManipulatorBaseSharedPtrInputManipulatorContainer
 Gets the input manipulator iterator.
 
typedef InputManipulatorContainer::iterator InputManipulatorIterator
 
typedef kanzi::vector< Node::MessageSubscriptionTokenMessageSubscriptionTokenVector
 
typedef NodeComponentContainer::const_iterator NodeComponentConstIterator
 
typedef vector< NodeComponentEntryNodeComponentContainer
 Gets the node component iterator.
 
typedef NodeComponentContainer::iterator NodeComponentIterator
 
enum  VerticalAlignment { VerticalAlignmentBottom , VerticalAlignmentTop , VerticalAlignmentCenter , VerticalAlignmentStretch }
 Vertical alignment options. More...
 
typedef function< VisitorResult(Node &) Visitor)
 Defines the type of the function that Kanzi executes for each node when visiting a node tree.
 
enum  VisitorOrder { VisitorPreOrder , VisitorPostOrder }
 Defines the order in which Kanzi visits the nodes in a node tree. More...
 
enum  VisitorResult { VisitorAbort , VisitorContinue , VisitorContinueSibling }
 Defines the return type of the Node::Visitor function. More...
 
- Public Types inherited from kanzi::PropertyObject
typedef PropertyStorageContainer::const_iterator PropertyStorageConstIterator
 
typedef vector< PropertyStoragePtrPropertyStorageContainer
 
typedef PropertyStorageContainer::iterator PropertyStorageIterator
 
typedef intrusive_ptr< AbstractPropertyTypeDescriptor::PropertyStoragePropertyStoragePtr
 
typedef PropertyStorageContainer::reverse_iterator PropertyStorageReverseIterator
 
- Public Types inherited from kanzi::BindingHostConcept
using BindingHostConceptSharedPtr
 Binding host concept shared pointer type.
 
using BindingRuntimeConstIterator
 Const iterator for binding runtimes.
 
using BindingRuntimeContainer
 Container for binding runtimes.
 
using BindingRuntimeIterator
 Iterator for binding runtimes.
 

Public Member Functions

bool addAbstractChildOverride (NodeSharedPtr child) override
 Node::addAbstractChildOverride() implementation.
 
void addChild (Node2DSharedPtr child)
 Adds a child node.
 
void arrange ()
 Performs layout arrangement on a 2D node.
 
ChildConstIterator beginChildren () const
 
bool compositionRequiresAlpha () const
 Returns whether composition requires alpha.
 
bool compositionRequiresDepth () const
 Returns whether composition requires depth.
 
bool compositionRequiresStencil () const
 Returns whether composition requires stencil.
 
optional< Vector2containsGlobal (Vector2 point) const
 Checks whether a node area contains a point defined in screen space. If it does, writes the node-space coordinates into the outgoing point.
 
bool containsLocal (Vector2 point) const
 Returns whether a node area contains a point defined in the local space of the node.
 
ChildConstIterator endChildren () const
 
NodeSharedPtr findAbstractChildOverride (string_view name) override
 Node::findAbstractChildOverride() implementation.
 
size_t getAbstractChildCountOverride () override
 Node::getAbstractChildCountOverride() implementation.
 
size_t getAbstractChildIndexOverride (const Node &node) override
 
NodeSharedPtr getAbstractChildOverride (size_t index) override
 Node::getAbstractChildOverride() implementation.
 
Vector2 getActualSize () const
 Gets the actual size of a node.
 
Vector2 getAllocatedSize () const
 Gets the allocated size of a node.
 
Matrix3x3 getArrangeTransform () const
 Gets the arrange transform.
 
BrushSharedPtr getBackgroundBrush () const
 Gets value of BackgroundBrushProperty.
 
BrushRenderergetBackgroundBrushRenderer () const
 Get background brush renderer.
 
QuadDescription getBackgroundQuad () const
 Gets the background quad description.
 
Node2DSharedPtr getChild (size_t index) const
 Returns a child from given index from object node.
 
Matrix3x3 getChildCompositionSpaceTransform () const
 Gets the transform used for composition children of the 2D node.
 
size_t getChildCount () const
 Gets the number of children of the node.
 
size_t getChildIndex (const Node &child) const
 Returns the index of a child in an object node.
 
ClippingArea getClippingArea () const
 Gets the clipping area.
 
BrushSharedPtr getCompositionBrush () const
 Gets value of CompositionBrushProperty.
 
BrushRenderergetCompositionBrushRenderer () const
 Access cache result brush renderer.
 
CompositionManagergetCompositionManager () const
 Access composition manager.
 
TextureSharedPtr getCompositionTarget () const
 Gets the composition target used for compositing the node.
 
NodeCompositor2DgetCompositor () const
 Accesses the compositor component.
 
Vector2 getContentDesiredSize () const
 Gets the size desired by content.
 
Vector2 getDesiredSize () const
 Gets the desired size of a node.
 
NodeEffect2DSharedPtr getEffect () const
 Gets the value of EffectProperty.
 
NodeEffectPrefab2DSharedPtr getEffectPrefab () const
 Gets the value of EffectPrefabProperty.
 
NodeEffectRenderer2DgetEffectRenderer () const
 Gets the effect renderer.
 
BrushSharedPtr getForegroundBrush () const
 Gets value of ForegroundBrushProperty.
 
BrushRenderergetForegroundBrushRenderer () const
 Get foreground brush renderer.
 
float getLayoutOpacity () const
 Gets the opacity after propagation from layouting hierarchy.
 
SRTValue2D getLayoutTransformation () const
 Gets the value of the LayoutTransformationProperty.
 
TextureSharedPtr getManagedCompositionTarget () const
 Gets the managed composition target of a node.
 
Matrix3x3 getParentSpaceTransform () const
 Gets the parent space transform of the 2D node.
 
Matrix3x3 getPartialArrangeTransform () const
 Gets the partial arrange transform.
 
NodeEffect2DgetRenderableEffect () const
 Gets a pointer to the current effect if effect rendering is required.
 
Matrix3x3 getRenderQuadTransform () const
 Gets transformation used to render the 2D node.
 
TextureSharedPtr getRenderTarget () const
 Gets value of RenderTargetProperty.
 
SRTValue2D getRenderTransformation () const
 Gets the value of RenderTransformationProperty.
 
RenderType getRenderType () const
 Get render type.
 
Vector2 getSecondPassDesiredSize () const
 Gets the second pass desired size.
 
Vector2 getUserDesiredSize () const
 Gets the size desired by user.
 
NodeVisual2DgetVisual () const
 Access visual component.
 
Matrix3x3 getWorldTransform () const
 Gets the world transformation matrix.
 
optional< Vector2globalToLocal (Vector2 point) const
 
bool hasCenterClipArea () const
 Returns whether a 2D node has the center clip area (the area of foreground content).
 
bool hasChild (const Node &child) const
 Returns whether the given node is a child of this node.
 
bool hasCompositionTarget () const
 Indicates whether the node has a composition target.
 
bool hasEffect () const
 Whether an active effect is applied to this node.
 
bool hasManagedCompositionTarget () const
 Returns whether the node has a managed composition target.
 
bool hasOutsideClipArea () const
 Returns whether a 2D node has outside clipping area.
 
bool hasTranslucentForeground () const
 Returns whether the foreground of a 2D node has translucency.
 
NodeSharedPtr hitTest (Vector2 point)
 Performs a hit test to a 2D node and all its child nodes.
 
template<typename T >
shared_ptr< ThitTest (Vector2 point)
 Wrapper for hitTest(Vector2), casts the return value.
 
NodeSharedPtr hitTest (Vector2 point, const Metaclass *type)
 Performs a hit test to a 2D node and all its child nodes.
 
template<typename T >
shared_ptr< ThitTest (Vector2 point, const Metaclass *type)
 Wrapper for hitTest(Vector2, const Metaclass), casts the return value.
 
virtual tuple< NodeSharedPtr, Ray, floathitTestContent (Vector2 point)
 Default implementation of Node2D content hit test.
 
NodeSharedPtr hitTestIterate (Vector2 point, HitTestVisitor visitor, void *userData)
 Hit tests nodes recursively from this node downwards and calls visitor function on the hit nodes.
 
void insertChild (size_t index, Node2DSharedPtr child)
 Adds a child node for object node to given index.
 
bool isCacheValid () const
 Returns whether the children cache is valid.
 
bool isClearColorAllowed () const
 Returns whether this Node2D is allowed and should clear the color buffer of its own composition target.
 
bool isCompletelyClipped () const
 Returns whether a node is completely clipped and needs not be rendered.
 
bool isCompletelyTransparent () const
 Returns whether a node is completely transparent.
 
bool isCompositionPotentiallyRequired () const
 Tell if node itself is going to get rendered into a composition target.
 
bool isPerspectiveTransformActive () const
 Returns whether a node is being perspective transformed.
 
bool isRenderChildrenAllowed () const
 Returns whether rendering children is allowed.
 
bool isRenderSelfAllowed () const
 Returns whether render self is allowed.
 
bool isSelfInCompositionTarget () const
 Returns whether the node is going to get rendered into a composition target.
 
bool isVisibleForHitTesting () const
 Returns whether a 2D node is visible for hit testing.
 
void layout ()
 Does layout pass with no root transformation (identity).
 
void layout (optional< Matrix3x3 > rootTransform)
 Does a layout pass starting from this node and iterating recursively all of its children.
 
bool measure (const Vector2 *availableSize, bool handleStretch)
 Measures one node.
 
virtual bool measureRecursive ()
 Performs measure recursively.
 
bool moveAbstractChildToPositionOverride (NodeSharedPtr child, size_t index) override
 Node::moveAbstractChildToPosition() implementation.
 
void moveChildToPosition (Node2DSharedPtr child, size_t index)
 Moves a child node to a given position in the list of child nodes.
 
void moveToBack ()
 Repositions the node to the beginning of its parent's children, so that it is drawn first.
 
void moveToFront ()
 Repositions the node to the end of its parent's children, so that it is drawn last.
 
ChildConstReverseIterator rbeginChildren () const
 
bool removeAbstractChildOverride (Node &child) override
 Node::removeAbstractChildOverride() implementation.
 
void removeAllChildren ()
 Removes all child nodes.
 
void removeChild (const Node &child)
 Removes child node.
 
void removeChild (size_t index)
 Removes child node at specified index.
 
ChildConstReverseIterator rendChildren () const
 
void render (Renderer3D &renderer, CompositionStack &compositionStack)
 Render a node and its descendant nodes.
 
void render (Renderer3D &renderer, CompositionStack &compositionStack, const optional< Matrix3x3 > &baseTransform)
 Renders a node and its descendant nodes.
 
bool requiresBackgroundBrushRendering () const
 Returns whether background brush rendering is required.
 
bool requiresForegroundBrushRendering () const
 Returns whether foreground brush rendering is required.
 
bool requiresLocalTransformationScope () const
 Indicates whether local transformation scope is required.
 
bool requiresTilingUpdate () const
 Returns whether node geometry requires an update for the tiling.
 
void resetCache ()
 Resets cached content for complete content of a node, including the node and its children.
 
void setActualSize (float sizeX, float sizeY)
 Sets the actual size of a node.
 
void setActualSize (Vector2 actualSize)
 Sets the actual size of a node.
 
void setAllocatedSize (Vector2 allocatedSize)
 Sets the allocated size of a node.
 
void setArrangeTransform (Matrix3x3 transform)
 Sets the arrange transform.
 
void setAutoHeight ()
 Sets a node to determine its height automatically.
 
void setAutoSize ()
 Sets a node to determine its width and height automatically.
 
void setAutoWidth ()
 Sets a node to determine its width automatically.
 
void setBackgroundBrush (BrushSharedPtr value)
 Sets value of BackgroundBrushProperty.
 
void setClearColorAllowed (bool enabled)
 Sets clear color allowed.
 
void setCompositionBrush (BrushSharedPtr value)
 Sets value of CompositionBrushProperty.
 
void setCompositionRequested (bool enabled)
 Turns the composition request on or off.
 
void setCompositionRequiresAlpha (bool enabled)
 Turns the composition alpha requirement on or off.
 
void setCompositionRequiresDepth (bool enabled)
 Turns the composition depth requirement on or off.
 
void setCompositionRequiresStencil (bool enabled)
 Turns the composition stencil requirement on or off.
 
void setDesiredSize (Vector2 desiredSize)
 Sets the desired size of a node.
 
void setEffectPrefab (NodeEffectPrefab2DSharedPtr value)
 Sets the value of EffectPrefabProperty.
 
void setForegroundBrush (BrushSharedPtr value)
 Sets value of ForegroundBrushProperty.
 
void setForegroundIsTranslucent (bool enabled)
 Sets the status of the foreground translucency.
 
void setForegroundTranslucencyRequested (bool enabled)
 Enables or disables the foreground translucency request.
 
KZ_DEPRECATED void setLayoutSize (float width, float height)
 Sets size properties of the node.
 
void setLayoutTransformation (SRTValue2D value)
 Sets the value of the LayoutTransformationProperty.
 
void setPotentialCompositionBitViewport (bool enabled)
 Turns the potential composition flag for the viewport on or off.
 
void setRenderTarget (TextureSharedPtr texture)
 Sets value of RenderTargetProperty.
 
void setRenderTransformation (SRTValue2D value)
 Sets the value of RenderTransformationProperty.
 
void setRequiresLocalTransformationScope (bool enabled)
 Sets the local transformation scope requirement.
 
void setRequiresTilingUpdate (bool enabled)
 Sets the tiling update requirement.
 
void setSize (float width, float height)
 Sets the size of a node.
 
void setSize (Vector2 size)
 Sets the size of a node.
 
void transform ()
 Transforms a 2D node.
 
VisitorResult visitAbstractChildOverride (const Visitor &visitor, VisitorOrder order) override
 Node::visitAbstractChild implementation.
 
 ~Node2D () override
 
- Public Member Functions inherited from kanzi::Node
ResourceSharedPtr acquireResource (const ResourceID &id) const
 Acquires a resource from the node or the node's closest ancestor having the resource id in the resource dictionary.
 
template<typename T >
shared_ptr< TacquireResource (const ResourceID &id) const
 Acquires a resource from the node or the node's closest ancestor having the resource id in the resource dictionary, and casts the resource to given type.
 
ResourceManager::AcquireTaskSharedPtr acquireResourceAsync (const ResourceID &key, ResourceManager::AsyncAcquireFinishedCallback func) const
 Posts an asynchronous task to acquire a resource.
 
ResourceDictionarySharedPtr acquireResourceDictionary ()
 Gets a resource dictionary of a node.
 
void addAnonymousResource (ResourceSharedPtr resource)
 Adds alias resource to an object node.
 
void addInputManipulator (InputManipulatorBaseSharedPtr inputManipulator)
 Transfers the ownership and attaches an input manipulator to an object node.
 
template<typename TMessageType >
MessageSubscriptionToken addMessageFilter (const TMessageType &messageType, typename TMessageType::FunctionType function)
 Adds a message filter where the filter is a function.
 
template<typename TMessageType , typename TClass , typename TClassMethod >
MessageSubscriptionToken addMessageFilter (TMessageType &messageType, TClass *messageHandlerObject, TClassMethod method)
 Adds a message filter where the filter is a method that is invoked on an object.
 
template<typename TMessageType >
MessageSubscriptionToken addMessageHandler (const TMessageType &messageType, typename TMessageType::FunctionType function)
 Adds a message handler where the handler is a function.
 
template<typename TMessageType >
MessageSubscriptionToken addMessageHandler (const TMessageType &messageType, typename TMessageType::FunctionType function, Node *messageSourceFilter)
 Adds a message handler where the handler is a function and you explicitly define the accepted source.
 
template<typename TMessageType , typename TClass , typename TClassMethod >
MessageSubscriptionToken addMessageHandler (TMessageType &messageType, TClass *messageHandlerObject, TClassMethod method)
 Adds a message handler where the handler is a method that is invoked on an object.
 
void addNodeComponent (NodeComponentSharedPtr nodeComponent)
 Transfers the ownership of a node component to an object node.
 
void addNodeComponentWithOwner (NodeComponentSharedPtr nodeComponent, const void *owner)
 Transfers the ownership of a node component to an object node and sets the owner of the node component.
 
void addNodeReference (AbstractPropertyType propertyType, AbstractNodeReference *reference)
 
void addResource (const ResourceID &resourceId, string_view resourceUrl)
 Adds a resource manager resource to an object node. If resourceID already exists in object, removes the existing entry. If resourceURL is NULL, error is thrown. *‍/.
 
void addResourceDictionary (ResourceDictionarySharedPtr resourceDictionary)
 Adds a nested resource dictionary to the resource dictionary of a node.
 
void addResourceReference (AbstractPropertyType propertyType, AbstractResourceReference *reference)
 This is a helper for automatic resource tracking in ResourceReference.
 
template<typename TMessageType , typename TClass , typename TClassMethod >
MessageSubscriptionToken addTunnelingFilter (const TMessageType &messageType, TClass *messageHandlerObject, TClassMethod method)
 Adds a message filter where the filter is a method that is invoked on an object.
 
template<typename TMessageType >
MessageSubscriptionToken addTunnelingFilter (const TMessageType &messageType, typename TMessageType::FunctionType function)
 Adds a message filter where the filter is a function.
 
template<typename TMessageType >
MessageSubscriptionToken addTunnelingHandler (const TMessageType &messageType, typename TMessageType::FunctionType function, Node *messageSourceFilter)
 Adds a message handler where the handler is a function and you explicitly define the accepted source.
 
AppliedStyleEntrySharedPtr applyManualStyle (StyleSharedPtr style)
 Applies a style to an object node.
 
AppliedStyleEntrySharedPtr applyStyle (StyleSharedPtr style)
 Applies a style to an object node.
 
void applyStyles ()
 Apply all styles for an object node.
 
void applyStylesRecursive ()
 Applies styles recursively.
 
void attachRecursive ()
 Attaches an object node and its children recursively.
 
InputManipulatorConstIterator beginInputManipulators () const
 
NodeComponentConstIterator beginNodeComponents () const
 
void clearChangeFlag (uint32_t flag)
 Clears a change flag.
 
void clearChildChangeFlag (uint32_t flag)
 Clears a child change flag.
 
bool containsResource (const ResourceID &resourceID) const
 Returns if object node resource dictionary contains the resource with given ID. Resource can be any type: style, alias or resource manager resource. *‍/.
 
BindingLookupContextPtr createLookupContext (NodeSharedPtr templateRoot)
 Creates a lookup context for the node.
 
void detachRecursive ()
 Detaches a node and its descendants.
 
void dispatchAbstractMessage (const AbstractMessageType &messageType, MessageArguments &messageArguments)
 Dispatches a message from this node with specified arguments.
 
template<typename TArgumentsType >
void dispatchMessage (const MessageType< TArgumentsType > &messageType, typename MessageType< TArgumentsType >::ArgumentsType &messageArguments)
 Dispatches a message from this node with specified arguments.
 
InputManipulatorConstIterator endInputManipulators () const
 
NodeComponentConstIterator endNodeComponents () const
 
template<typename TNodeType >
shared_ptr< TNodeTypefindAbstractChild (string_view name)
 Find a child by name. Finds direct children as well as children connected indirectly for example Viewport->Scene.
 
optional< string > findResourceURL (const ResourceID &resourceId) const
 Tries to find Resource URL for Resource ID from this node.
 
template<typename DataType >
DataType getAbstractProperty (AbstractPropertyType abstractPropertyType) const
 
uint32_t getChangeFlags () const
 Get current change flags.
 
uint32_t getChildChangeFlags () const
 Get current child change flags.
 
FocusManagergetFocusManager () const
 Returns the Focus Manager associated with the Screen node to which this node belongs.
 
FocusScopegetFocusScopeInfo () const
 Returns the information about the focus scope for a node.
 
InputManagergetInputManager () const
 Returns the Input Manager associated with the Screen node to which this node belongs.
 
AbstractPropertyTypeDescriptor::ValueSourcegetNodeFinalValueSource (AbstractPropertyTypeDescriptor &descriptor) const
 
template<typename DataType >
optional< typename PropertyType< DataType >::DataType > getOptionalAbstractProperty (AbstractPropertyType abstractPropertyType) const
 
template<typename DataType >
optional< typename PropertyType< DataType >::Traits::ReturnType > getOptionalProperty (const PropertyType< DataType > &propertyType) const
 Evaluates the property value in the same way as the overload above but does not default to the value in property metadata if there are no inputs to the property value.
 
NodegetParent () const
 Returns the parent of the node.
 
template<typename DataType >
PropertyType< DataType >::Traits::ReturnType getProperty (const PropertyType< DataType > &propertyType) const
 Returns the current value of a property.
 
ResourceDictionarySharedPtr getResourceDictionary () const
 If a node has a resource dictionary, returns the resource dictionary of that node.
 
ScreengetScreen () const
 Returns the Screen node to which this node belongs.
 
NodeSharedPtr getTemplateRoot () const
 Gets the template root of this node.
 
void invalidateArrange ()
 Invalidates arrange.
 
void invalidateDraw ()
 Invalidates draw flag for the node.
 
void invalidateFinalTransform ()
 Invalidates final transform for node.
 
void invalidateMeasure ()
 Invalidates measure for the node.
 
void invalidateRender ()
 Invalidates render for node.
 
bool isAnyChangeFlagSet (uint32_t flag) const
 Checks if any of given flags is set.
 
bool isAnyChildChangeFlagSet (uint32_t flag) const
 Checks if any child change flags (corresponding to given mask) are set.
 
bool isAttached () const
 Returns true if the node is attached to a screen or one of its descendants.
 
bool isAttaching () const
 Returns true if node is in the process of attaching, false otherwise.
 
bool isChangeFlagSet (uint32_t flag) const
 Checks if a change flag is set.
 
bool isChildChangeFlagSet (uint32_t flag) const
 Checks if child change flags match.
 
bool isDetaching () const
 Returns true if the node currently detaching.
 
bool isEffectivelyFocusable () const
 Returns whether a node is focusable.
 
bool isEffectivelyVisible () const
 Returns whether a node and its ancestor nodes are visible.
 
bool isInitialized () const
 Returns true if initialize() has been called, false otherwise.
 
bool isInvalidArrange () const
 Checks if the node needs arrange.
 
bool isInvalidDraw ()
 Tells if node draw flag is invalid.
 
bool isInvalidFinalTransform () const
 Tells if final transform flag is invalid for node.
 
bool isInvalidMeasure () const
 Check if the node needs measure.
 
bool isInvalidRender () const
 Returns if node render flag is invalid.
 
bool isNamed (string_view name) const
 
 KZ_METACLASS_PROPERTY_TYPE (FontFamilyProperty)
 
template<typename Type >
shared_ptr< Type > lookupNode (string_view pathOrKey)
 Returns a node of specified type by looking it up with specified path or alias.
 
template<typename Type >
shared_ptr< Type > lookupNodeComponent (string_view name)
 Returns a node component of specified type by looking it up with specified name.
 
NodelookupNodeRaw (string_view relativePath)
 Get an object node by another node and a relative path.
 
ObjectSharedPtr lookupObject (string_view relativePath)
 Lookup for an object from a node.
 
template<typename Type >
shared_ptr< Type > lookupObject (string_view relativePath)
 Lookup for an object from a node.
 
tuple< NodeSharedPtr, AbstractPropertyTypelookupObjectForStateManager (string_view relativePath)
 Lookup for an node and possible object from within the node for state manager.
 
void notifyResourceDictionaryModified ()
 Forces the re-evaluation of resource IDs in a node tree.
 
void removeAnonymousResource (const Resource &resource)
 Removes anonymous resource from object node resources.
 
void removeInputManipulator (InputManipulator &inputManipulator)
 Removes the ownership and detaches an input manipulator from an object node.
 
void removeKZBData ()
 Destroys all object node data loaded from KZB.
 
void removeKZBData (flat_set< AbstractPropertyType > *keepProperties)
 Destroys all object node data loaded from KZB, including properties, bindings, node components, resources etc.
 
void removeMessageHandler (MessageSubscriptionToken token)
 Removes a message subscription.
 
void removeNodeComponent (NodeComponent &nodeComponent)
 Removes the ownership of a node component from an object node.
 
void removeNodeComponentWithOwner (const void *owner)
 Removes all bindings with the specified owner.
 
void removeNodeReference (const AbstractNodeReference &reference)
 
void removeResource (const ResourceID &resourceId)
 Removes a resource with given ID from object node resource dictionary. Does not do anything if resourceID was not found. *‍/.
 
void removeResourceReference (const AbstractResourceReference &reference)
 This is a helper for automatic resource tracking in ResourceReference.
 
void setChangeFlag (uint32_t flag)
 Sets a change flag.
 
void setChildChangeFlag (uint32_t flag)
 Sets a child change flag.
 
void setParent (Node *parent)
 Kanzi uses this method internally to set the parent of a node.
 
void setResourceDictionary (ResourceDictionarySharedPtr resourceDictionary)
 Replaces the resource dictionary of a node.
 
void setScreen (Screen *screen)
 Sets the Screen node to which this node belongs.
 
void setTemplateRoot (NodeSharedPtr templateRoot)
 Sets the template root of this node.
 
ResourceSharedPtr tryAcquireResource (const ResourceID &id) const
 Acquires a resource from the node or the node's closest ancestor having the resource id in the resource dictionary.
 
template<typename T >
shared_ptr< TtryAcquireResource (const ResourceID &id) const
 Acquires a resource from the node or the node's closest ancestor having the resource and casts the resource to given type.
 
KZ_DEPRECATED NodeSharedPtr trySetActiveFocus ()
 Tries to move the focus on this node.
 
NodeSharedPtr trySetFocus ()
 Tries to move the focus to this node.
 
NodeSharedPtr trySetFocus (FocusFallback fallbackOption)
 Tries to set the focus to the newFocusNode using FocusManager::trySetFocus() but with a fallback behavior in case the node does not gain focus.
 
void unapplyStyle (AppliedStyleEntrySharedPtr appliedStyleEntry)
 Unapplies a style from an object node.
 
void unapplyStyles ()
 Unapplies and removes all applied styles.
 
void unapplyStylesRecursive ()
 Unapplies styles recursively.
 
void validateArrange ()
 Validates arrange.
 
void validateDraw ()
 Validates draw flags for the node.
 
void validateDrawForChildrenRecursive ()
 Recursively validates draw for the children from this 2D node onwards.
 
void validateMeasure ()
 Validates measure for the node.
 
void validateRender ()
 Validates render for node.
 
VisitorResult visit (const Visitor &visitor, VisitorOrder order)
 Visits a node and its descendants.
 
VisitorResult visitDescendants (const Visitor &visitor, VisitorOrder order)
 Visits the descendants of a node.
 
 ~Node () override
 Destructor.
 
string getName () const
 Gets the value of NameProperty.
 
void setName (string_view value)
 Sets the value of NameProperty.
 
string getPath () const
 Gets the value of PathProperty.
 
void setPath (string value)
 Sets the value of PathProperty.
 
string getLocale () const
 Gets the value of LocaleProperty.
 
void setLocale (string value)
 Sets the value of LocaleProperty.
 
bool isHitTestable () const
 Gets the value of HitTestableProperty.
 
void setHitTestable (bool value)
 Sets the value of HitTestableProperty.
 
bool isHitTestableContainer () const
 Gets the value of HitTestableContainerProperty.
 
void setHitTestableContainer (bool value)
 Sets the value of HitTestableContainerProperty.
 
bool isVisible () const
 Gets the value of VisibleProperty.
 
void setVisible (bool value)
 Sets the value of VisibleProperty.
 
bool isEnabled () const
 Returns the value of the EnabledProperty.
 
void setEnabled (bool value)
 Sets the value of the EnabledProperty.
 
bool isEffectivelyEnabled () const
 Returns the value of EffectivelyEnabledProperty.
 
bool isFocusable () const
 Gets the value of the FocusableProperty.
 
void setFocusable (bool value)
 Sets the value of the FocusableProperty.
 
bool isFocused () const
 Gets the value of the FocusedProperty.
 
void setFocused (bool value)
 Sets the value of the FocusedProperty.
 
FocusState getFocusState () const
 Gets the value of the FocusStateProperty.
 
void setFocusState (FocusState state)
 Sets the value of the FocusStateProperty.
 
FontFamilySharedPtr getFontFamily () const
 Gets the font family the node uses.
 
void setFontFamily (FontFamilySharedPtr value)
 Sets the font family the node uses.
 
float getVisibleAmountInParent () const
 Gets the value of VisibleAmountInParentProperty.
 
void setVisibleAmountInParent (float value)
 Sets the value of VisibleAmountInParentProperty.
 
float getProjection2DTo3DScale () const
 Gets the value of Projection2DTo3DScaleProperty.
 
void setProjection2DTo3DScale (float value)
 Sets the value of Projection2DTo3DScaleProperty.
 
ResourceSharedPtr getStyle () const
 Gets the value of StyleProperty.
 
void setStyle (ResourceSharedPtr value)
 Sets the value of StyleProperty.
 
ResourceSharedPtr getStateManager () const
 Gets the value of StateManagerProperty.
 
void setStateManager (ResourceSharedPtr value)
 Sets the value of StateManagerProperty.
 
float getWidth () const
 Gets the value of WidthProperty.
 
void setWidth (float value)
 Sets the value of WidthProperty.
 
float getHeight () const
 Gets the value of HeightProperty.
 
void setHeight (float value)
 Sets the value of HeightProperty.
 
float getDepth () const
 Gets the value of DepthProperty.
 
void setDepth (float value)
 Sets the value of DepthProperty.
 
float getActualWidth () const
 Gets the value of ActualWidthProperty.
 
void setActualWidth (float value)
 Sets the value of ActualWidthProperty.
 
float getActualHeight () const
 Gets the value of ActualHeightProperty.
 
void setActualHeight (float value)
 Sets the value of ActualHeightProperty.
 
float getActualDepth () const
 Gets the value of ActualDepthProperty.
 
void setActualDepth (float value)
 Sets the value of ActualDepthProperty.
 
Node::HorizontalAlignment getHorizontalAlignment () const
 Gets the value of HorizontalAlignmentProperty.
 
void setHorizontalAlignment (Node::HorizontalAlignment value)
 Sets the value of HorizontalAlignmentProperty.
 
Node::VerticalAlignment getVerticalAlignment () const
 Gets the value of VerticalAlignmentProperty.
 
void setVerticalAlignment (Node::VerticalAlignment value)
 Sets the value of VerticalAlignmentProperty.
 
Node::DepthAlignment getDepthAlignment () const
 Gets the value of DepthAlignmentProperty.
 
void setDepthAlignment (Node::DepthAlignment value)
 Sets the value of DepthAlignmentProperty.
 
Vector2 getHorizontalMargin () const
 Gets the value of HorizontalMarginProperty.
 
void setHorizontalMargin (Vector2 value)
 Sets the value of HorizontalMarginProperty.
 
Vector2 getVerticalMargin () const
 Gets the value of VerticalMarginProperty.
 
void setVerticalMargin (Vector2 value)
 Sets the value of VerticalMarginProperty.
 
Vector2 getDepthMargin () const
 Gets the value of DepthMarginProperty.
 
void setDepthMargin (Vector2 value)
 Sets the value of DepthMarginProperty.
 
Node::ContentStretch getContentStretch () const
 Gets the value of ContentStretchProperty.
 
void setContentStretch (Node::ContentStretch value)
 Sets the value of ContentStretchProperty.
 
float getOpacity () const
 Gets the value of OpacityProperty.
 
void setOpacity (float value)
 Sets the value of OpacityProperty.
 
bool isHover () const
 Returns whether the node has HoverProperty set to true.
 
bool isClipChildren () const
 Gets the value of ClipChildrenProperty.
 
void setClipChildren (bool value)
 Sets the value of ClipChildrenProperty.
 
- Public Member Functions inherited from kanzi::Object
AppliedStyleEntrySharedPtr applyObjectStyle (kanzi::StyleSharedPtr style)
 Applies a style to an object.
 
void applyObjectStyles ()
 Apply all styles for an object node.
 
DomaingetDomain () const
 Returns the domain the object belongs to.
 
const MetaclassgetDynamicMetaclass () const override
 Returns the metaclass of the dynamic type of the object.
 
MainLoopSchedulergetMainLoopScheduler () const
 Returns the MainLoopScheduler instance of the associated Domain.
 
detail::MessageDispatcher * getMessageDispatcher () const
 Returns the message dispatcher of the object.
 
ResourceManagergetResourceManager () const
 Returns the resource manager of the object.
 
ScriptingContextSharedPtr getScriptingContext () const
 Gets the scripting context of the object.
 
 Object (Domain *domain)
 
void setScriptingContext (ScriptingContextSharedPtr context)
 Sets the scripting context of the object.
 
void unapplyObjectStyle (AppliedStyleEntrySharedPtr appliedStyleEntry)
 
void unapplyObjectStyles ()
 Unapplies and removes all applied styles.
 
 ~Object () override
 
- Public Member Functions inherited from kanzi::MetaObject
bool isTypeOf (const Metaclass *objectType) const
 Determines if the type of this object is the given type or derived from it.
 
virtual ~MetaObject ()
 
- Public Member Functions inherited from kanzi::PropertyObject
template<typename DataType >
void addPropertyModifier (const PropertyType< DataType > &propertyType, typename PropertyType< DataType >::Descriptor::ModifierCallback callback, void *owner)
 
template<typename DataType >
void addPropertyModifierWithoutNotifyingHandlers (const PropertyType< DataType > &propertyType, typename PropertyType< DataType >::Descriptor::ModifierCallback callback, void *owner)
 Adds a property modifier without notifying handlers.
 
template<typename DataType >
void addPropertyNotificationHandler (const PropertyType< DataType > &propertyType, typename PropertyType< DataType >::Descriptor::NotificationCallback callback, void *owner)
 
template<typename DataType >
void addPropertyValueSource (const PropertyType< DataType > &propertyType, typename PropertyType< DataType >::Descriptor::TypedValueSource *valueSource, PropertyValuePrecedence precedence, AbstractPropertyTypeDescriptor::ValueSourceOwner *owner)
 
template<typename DataType >
void addPropertyValueSource (const PropertyType< DataType > &propertyType, typename PropertyType< DataType >::Descriptor::TypedValueSource *valueSource, PropertyValuePrecedence precedence, void *ownerPointer)
 
PropertyStorageContainer::iterator beginPropertyStorage ()
 Returns the begin iterator to the internal property storage container.
 
PropertyStorageContainer::const_iterator beginPropertyStorage () const
 Returns the begin iterator to the internal property storage container.
 
void clearPropertyFlag (AbstractPropertyType propertyType, uint32_t flag)
 
void copyLocalValue (const PropertyObject &other, AbstractPropertyType propertyType)
 Copies local value of single property from another object.
 
void copyLocalValues (const PropertyObject &other)
 Copies all local values from another object.
 
PropertyStorageContainer::iterator endPropertyStorage ()
 Returns the end iterator to the internal property storage container.
 
PropertyStorageContainer::const_iterator endPropertyStorage () const
 Returns the end iterator to the internal property storage container.
 
template<typename DataType >
PropertyType< DataType >::Traits::ReturnType getAbstractProperty (AbstractPropertyType abstractPropertyType) const
 
template<typename DataType >
PropertyType< DataType >::Traits::ReturnType getAbstractPropertyBase (AbstractPropertyType abstractPropertyType) const
 
template<typename DataType >
optional< typename PropertyType< DataType >::Traits::ReturnType > getOptionalAbstractProperty (AbstractPropertyType abstractPropertyType) const
 
template<typename DataType >
optional< typename PropertyType< DataType >::Traits::ReturnType > getOptionalProperty (const PropertyType< DataType > &propertyType) const
 Evaluates the property value in the same way as the overload above but does not default to the value in property metadata if there are no inputs to the property value.
 
template<typename DataType >
optional< typename PropertyType< DataType >::Traits::ReturnType > getOptionalPropertyBase (const PropertyType< DataType > &propertyType) const
 Returns the current value of a property disregarding modifiers, but does not default to the value in property metadata if there are no inputs to the property value.
 
template<typename DataType >
PropertyType< DataType >::Traits::ReturnType getProperty (const PropertyType< DataType > &propertyType) const
 Returns the current value of a property type.
 
template<typename DataType >
PropertyType< DataType >::Traits::ReturnType getPropertyBase (const PropertyType< DataType > &propertyType) const
 Returns the current value of a property disregarding modifiers.
 
template<typename DataType >
size_t getPropertyNotificationHandlerCount (const PropertyType< DataType > &propertyType) const
 Gets number of current notification handlers for given property type.
 
bool hasBaseValue (AbstractPropertyType propertyType) const
 Evaluates whether there are any inputs into the property value, disregarding modifiers.
 
bool hasLocalValue (AbstractPropertyType propertyType) const
 Evaluates whether there is a local value set for the property.
 
bool hasNonClassValue (AbstractPropertyType propertyType) const
 Evaluates whether there is a value of any precedence higher than class default value set for the property.
 
bool hasValue (AbstractPropertyType propertyType) const
 Evaluates whether there are any inputs into the property value.
 
bool isPropertyFlagSet (AbstractPropertyType propertyType, uint32_t flag) const
 
 PropertyObject ()
 
void removeKzbProperties ()
 Remove all KZB properties.
 
void removeKzbProperties (flat_set< AbstractPropertyType > *keepProperties)
 Remove all KZB properties that are not included in a given set.
 
template<typename DataType >
void removeLocalPropertyValueSource (const PropertyType< DataType > &propertyType, typename PropertyType< DataType >::Descriptor::TypedValueSource *valueSource, void *ownerPointer)
 
void removeLocalValue (AbstractPropertyType propertyType)
 Removes the local value associated with the property.
 
template<typename DataType >
void removePropertyModifier (const PropertyType< DataType > &propertyType, typename PropertyType< DataType >::Descriptor::ModifierCallback callback, void *owner)
 
template<typename DataType >
void removePropertyNotificationHandler (const PropertyType< DataType > &propertyType, typename PropertyType< DataType >::Descriptor::NotificationCallback callback, void *owner)
 
template<typename DataType >
void removePropertyValueSource (const PropertyType< DataType > &propertyType, typename PropertyType< DataType >::Descriptor::TypedValueSource *valueSource, void *ownerPointer)
 
template<typename DataType >
void setAbstractProperty (AbstractPropertyType abstractPropertyType, typename PropertyType< DataType >::Traits::ParameterType value)
 
template<typename DataType >
void setProperty (const PropertyType< DataType > &propertyType, typename PropertyType< DataType >::Traits::ParameterType value)
 Sets the local value of a property type.
 
void setPropertyFlag (AbstractPropertyType propertyType, uint32_t flag)
 
KZ_DEPRECATED void validatePropertyModifiers (AbstractPropertyType propertyType)
 Validates property modifiers and notifies handlers.
 
void validatePropertyModifiersAndNotifyHandlers (AbstractPropertyType propertyType)
 Validates property modifiers and notifies handlers.
 
virtual ~PropertyObject ()
 
- Public Member Functions inherited from kanzi::BindingHostConceptImpl< Node >
void addBindingRuntime (AbstractBindingRuntimeSharedPtr entry, shared_ptr< void > owner)
 Adds an already-created binding runtime to this binding host.
 
BindingRuntimeHandle setBinding (AbstractBindingSharedPtr binding)
 Wrapper for setting a binding with no target.
 
BindingRuntimeHandle setBinding (AbstractBindingSharedPtr binding, AbstractPropertyType propertyType)
 Wrapper for setting a binding.
 
BindingRuntimeHandle setBinding (AbstractBindingSharedPtr binding, AbstractPropertyType propertyType, PropertyField field)
 Wrapper for setting a binding.
 
BindingRuntimeHandle setBinding (AbstractBindingSharedPtr binding, AbstractPropertyType propertyType, PropertyField field, PropertyValuePrecedence precedence)
 Wrapper for setting a binding.
 
BindingRuntimeHandle setBinding (AbstractBindingSharedPtr binding, AbstractPropertyType propertyType, PropertyValuePrecedence precedence)
 Wrapper for setting a binding.
 
BindingRuntimeHandle setBinding (AbstractBindingSharedPtr binding, shared_ptr< Node > templateRoot)
 Sets a binding with no target.
 
BindingRuntimeHandle setBinding (AbstractBindingSharedPtr binding, shared_ptr< Node > templateRoot, AbstractPropertyType propertyType, PropertyField field)
 Wrapper for setting a binding.
 
BindingRuntimeHandle setBinding (AbstractBindingSharedPtr binding, shared_ptr< Node > templateRoot, AbstractPropertyType propertyType, PropertyField field, PropertyValuePrecedence precedence)
 Wrapper for setting a binding.
 
BindingRuntimeHandle setBinding (AbstractBindingSharedPtr binding, shared_ptr< Node > templateRoot, AbstractPropertyType propertyType, PropertyValuePrecedence precedence)
 Wrapper for setting a binding.
 
BindingRuntimeHandle setBindingWithOwner (AbstractBindingSharedPtr binding, shared_ptr< void > owner)
 Wrapper for setting a binding with no target.
 
BindingRuntimeHandle setBindingWithOwner (AbstractBindingSharedPtr binding, shared_ptr< void > owner, AbstractPropertyType propertyType)
 Wrapper for setting a binding with owner.
 
BindingRuntimeHandle setBindingWithOwner (AbstractBindingSharedPtr binding, shared_ptr< void > owner, AbstractPropertyType propertyType, PropertyField field, PropertyValuePrecedence precedence)
 Wrapper for setting a binding with owner.
 
BindingRuntimeHandle setBindingWithOwner (AbstractBindingSharedPtr binding, shared_ptr< void > owner, shared_ptr< Node > templateRoot)
 Sets a binding with no target.
 
BindingRuntimeHandle setBindingWithOwner (AbstractBindingSharedPtr binding, shared_ptr< void > owner, shared_ptr< Node > templateRoot, AbstractPropertyType propertyType, PropertyField field, PropertyValuePrecedence precedence)
 Sets a binding to a certain property.
 
BindingRuntimeHandle setModifierBinding (AbstractBindingSharedPtr binding, AbstractPropertyType propertyType)
 Wrapper for setting a modifier binding.
 
BindingRuntimeHandle setModifierBinding (AbstractBindingSharedPtr binding, AbstractPropertyType propertyType, PropertyField field)
 Wrapper for setting a modifier binding.
 
BindingRuntimeHandle setModifierBinding (AbstractBindingSharedPtr binding, shared_ptr< Node > templateRoot, AbstractPropertyType propertyType, PropertyField field)
 Wrapper for setting a modifier binding.
 
BindingRuntimeHandle setModifierBindingWithOwner (AbstractBindingSharedPtr binding, shared_ptr< void > owner, AbstractPropertyType propertyType)
 Wrapper for setting a modifier binding.
 
BindingRuntimeHandle setModifierBindingWithOwner (AbstractBindingSharedPtr binding, shared_ptr< void > owner, AbstractPropertyType propertyType, PropertyField field)
 Wrapper for setting a modifier binding.
 
BindingRuntimeHandle setModifierBindingWithOwner (AbstractBindingSharedPtr binding, shared_ptr< void > owner, shared_ptr< Node > templateRoot, AbstractPropertyType propertyType, PropertyField field)
 Sets a modifier binding.
 
- Public Member Functions inherited from kanzi::BindingHostConcept
BindingRuntimeConstIterator beginBindingRuntimes () const
 Returns an iterator to the beginning of binding runtimes.
 
BindingRuntimeConstIterator endBindingRuntimes () const
 Returns an iterator to the end of binding runtimes.
 
AbstractBindingRuntimeSharedPtr getBindingRuntime (size_t idx)
 Gets binding by index.
 
size_t getBindingRuntimeCount () const
 Gets the number of binding runtimes added to this node.
 
void removeAllBindings ()
 Removes all binding runtimes.
 
void removeBinding (BindingRuntimeHandle &bindingRuntime)
 Removes a binding runtime added earlier.
 
void removeBindingsWithOwner (shared_ptr< void > owner)
 Removes all binding runtimes with the specified owner.
 

Static Public Member Functions

static bool isUnboundedLayoutSize (Vector2 layoutSize)
 Returns whether a layout size is an unbound layout size.
 
static bool isValidLayoutSize (Vector2 size)
 Returns whether a size is a valid layout size.
 
static float layoutUp ()
 Returns the direction to which the y axis grows for this node type.
 
static PropertyTypeEditorInfoSharedPtr makeEditorInfo ()
 
static Vector2 replaceUnboundedLayoutSize (Vector2 layoutSize, Vector2 resetSize)
 Replaces any element of a layout size with appropriate element of the reset size if it is unbounded and returns the size.
 
static Vector2 replaceUnboundedLayoutSizeWithZero (Vector2 layoutSize)
 Replaces any element of a layout size with zero if it is unbounded and returns the size.
 
static Vector2 unboundedLayoutSize ()
 Returns an unbound layout size.
 
- Static Public Member Functions inherited from kanzi::Node
static bool isUnboundedLayoutValue (float layoutValue)
 Indicates whether a value is an unbound layout value.
 
static bool isValidLayoutValue (float value)
 Indicates whether a value is valid layout value.
 
static float replaceUnboundedLayoutValue (float layoutValue, float resetValue)
 Replaces layout value with the specified value if it is unbounded and returns it.
 
static float replaceUnboundedLayoutValueWithZero (float layoutValue)
 Replaces layout value with zero if it is unbounded layout value and returns it.
 
static float unboundedLayoutValue ()
 Returns an unbounded layout value.
 
- Static Public Member Functions inherited from kanzi::Object
static const MetaclassgetStaticMetaclass ()
 Returns the metaclass of Object class.
 
static PropertyTypeEditorInfoSharedPtr makeEditorInfo ()
 Default implementation that returns empty editor info.
 
- Static Public Member Functions inherited from kanzi::MetaObject
static const MetaclassgetStaticMetaclass ()
 Returns the metaclass of Object class.
 
static PropertyTypeEditorInfoSharedPtr makeEditorInfo ()
 Default implementation that returns empty editor info.
 

Protected Types

enum  Node2DFlags {
  AllowClear , AllowRenderChildren , AllowRenderSelf , ForegroundIsTranslucent ,
  ForegroundTranslucencyRequested , RequiresBackgroundQuad , RequiresLocalTransformationScope , RequiresTilingUpdate ,
  Node2DFlagsBitCount
}
 Different Node2D flags for bit set. More...
 
- Protected Types inherited from kanzi::Object
typedef vector< AppliedStyleEntrySharedPtrAppliedStyleContainer
 Applied style container.
 

Protected Member Functions

NodeCompositor2DacquireCompositor ()
 Initializes and returns composition structure.
 
NodeVisual2DacquireVisual ()
 Initializes and returns visual structure.
 
Matrix3x3 applyCompositionForRenderSelf (Renderer3D &renderer, CompositionStack &compositionStack, const optional< Matrix3x3 > &baseTransform)
 Applies composition for rendering the node.
 
virtual void arrangeOverride (Vector2 actualSize)
 Default implementation of Node2D arrange.
 
virtual void arrangeRecursive (const Matrix3x3 &worldTransform, const Matrix3x3 &parentTransform, bool arrangeNeeded, bool transformChanged)
 Perform arrange recursively.
 
ClippingArea calculateClippingArea (const Matrix3x3 &parentSpaceTransform) const
 Calculates clipping parameters.
 
optional< QuadDescriptioncalculateContentStretch (Vector2 renderSize, Vector2 contentSize)
 Calculates content stretch.
 
bool calculatePerspectiveTransformMatrices (int viewportWidth, int viewportHeight, Matrix4x4 &cameraMatrix, Matrix4x4 &projectionMatrix) const
 Calculate perspective transform matrices.
 
void calculateTransformedBoundingArea (const Matrix3x3 &transform, Vector2 sizeIn)
 Calculates new transformed bounding area.
 
void clearCompositionTarget (Renderer3D &renderer, CompositionStack &compositionStack)
 Clears the composition target of a 2D node.
 
Vector2 getDesiredSizeAxisAlignedBoundingBoxMaximum () const
 Gets the desired size axis aligned bounding box maximum.
 
Vector2 getDesiredSizeAxisAlignedBoundingBoxMinimum () const
 Gets the desired size axis aligned bounding box minimum.
 
optional< floatgetUserAspectRatio () const
 Gets the value of the aspect ratio property assigned to a node.
 
optional< floatgetUserHeight () const
 Gets the value of the layout height property assigned to a node.
 
optional< floatgetUserWidth () const
 Gets the value of the layout width property assigned to a node.
 
void initialize ()
 Node2D -specific initialization.
 
bool isEmptyActualSize () const
 Returns whether the size of the node is empty or invalid.
 
bool isForegroundHintOpaque () const
 Indicates whether foreground hint is opaque.
 
bool isForegroundHintTranslucent () const
 Indicates whether foreground hint is translucent.
 
virtual Vector2 measureOverride (Vector2 availableSize)
 Default implementation of Node2D size calculation.
 
 Node2D (Domain *domain, string_view name)
 Constructor.
 
void onAttached () override
 Node::onDetached() implementation.
 
void onDetached () override
 Node::onDetached() implementation.
 
void onNodePropertyChanged (AbstractPropertyType propertyType, PropertyNotificationReason reason) override
 Node::onNodePropertyChanged implementation.
 
virtual void onTransform ()
 Node2D transform function.
 
unsigned int performClipping (QuadDescription &backgroundQuad, optional< QuadDescription > &foregroundQuad, optional< QuadDescription > &effectQuad, unsigned int clippingResult)
 Performs rectangle clipping.
 
bool pushLocalViewportArea (CompositionStack &compositionStack, const optional< Matrix3x3 > &baseTransform)
 Pushes local viewport and scissor area into composition stack if it is required.
 
void renderBackground (Renderer3D &renderer, const CompositionStack &compositionStack, const Matrix3x3 &transform)
 Renders the background quad of a Node2D.
 
void renderChildren (Renderer3D &renderer, CompositionStack &compositionStack, const optional< Matrix3x3 > &baseTransform)
 Renders all children of a Node2D.
 
void renderForeground (Renderer3D &renderer, CompositionStack &compositionStack, const Matrix3x3 &transform)
 Renders the foreground of a Node2D.
 
virtual void renderForegroundOverride (Renderer3D &renderer, CompositionStack &compositionStack, const Matrix3x3 &transform)
 Node-specific foreground render.
 
virtual void renderOverride (Renderer3D &renderer, CompositionStack &compositionStack, const optional< Matrix3x3 > &baseTransform)
 Node-specific top-level render call.
 
void renderRecursive (Renderer3D &renderer, CompositionStack &compositionStack, const optional< Matrix3x3 > &baseTransform)
 Renders a Node2D and then recursively all its children.
 
virtual void renderSelfOverride (Renderer3D &renderer, CompositionStack &compositionStack, const optional< Matrix3x3 > &baseTransform)
 Node-specific rendering.
 
void restoreResources () override
 Node::restoreResources() implementation.
 
void setDesiredSizeAxisAlignedBoundingBoxMaximum (float sizeX, float sizeY)
 Sets the desired size maximum.
 
void setDesiredSizeAxisAlignedBoundingBoxMaximum (Vector2 size)
 Sets the desired size axis aligned bounding box maximum.
 
void setDesiredSizeAxisAlignedBoundingBoxMinimum (float sizeX, float sizeY)
 Sets the desired size axis aligned bounding box minimum.
 
void setDesiredSizeAxisAlignedBoundingBoxMinimum (Vector2 size)
 Sets the desired size axis aligned bounding box minimum.
 
void setEffect (NodeEffect2DSharedPtr value)
 Sets the value of EffectProperty.
 
void setPartialArrangeTransform (Matrix3x3 transform)
 Sets partial arrange transform.
 
void setRenderChildrenAllowed (bool enabled)
 Turn render children on or off.
 
void setRenderSelfAllowed (bool enabled)
 Turn render self on or off.
 
void setRenderType (RenderType renderType)
 Set render type.
 
void setSecondPassDesiredSize (Vector2 size)
 Set second pass desired size.
 
void updateContentTexture (TextureSharedPtr texture)
 Update content texture for the foreground brush.
 
void updateFinalTransform (const Matrix3x3 &worldTransform, const Matrix3x3 &parentTransform)
 Updates the transformation status based on node properties and calculations in measure and arrange phases.
 
bool updateRender (const Matrix3x3 &worldTransform, const Matrix3x3 &parentTransform, bool transformChanged)
 Validates a node for rendering.
 
virtual void updateRenderOverride ()
 Node-specific updates done before render.
 
- Protected Member Functions inherited from kanzi::Node
void attach ()
 Attaches the object node.
 
void detach ()
 Detaches the object node.
 
void initialize ()
 Node-specific initialization.
 
 Node (Domain *domain, string_view name)
 Constructor.
 
void notifyPropertyHandlers (PropertyStoragePtr &propertyStorage, PropertyNotificationReason reason) override
 Notifies all property handlers on a property storage.
 
virtual void updateFocusScopeInfo (FocusScopePtr &nodeScopeInfo)
 Updates the overlay scope information that is attached to the root node of an overlay scope.
 
void updatePropertiesForConnectedNode ()
 Invokes property notifications for inherited properties during node tree connections.
 
void updatePropertiesForDisconnectedNode (Node *oldParent)
 Invokes property notifications for inherited properties during node tree disconnections.
 
void updateResourceReferences ()
 
void updateResourceReferences (AbstractPropertyType propertyType)
 
void updateResourceReferencesRecursive ()
 
void updateResourceReferencesRecursive (const ResourceID &resourceID)
 
- Protected Member Functions inherited from kanzi::Object
void initialize ()
 
void onCopy (const Object &other)
 
- Protected Member Functions inherited from kanzi::MetaObject
void initialize ()
 
 MetaObject ()
 
- Protected Member Functions inherited from kanzi::PropertyObject
AbstractPropertyTypeDescriptor::ValueSourceEntryacquireLocalValueSourceEntry (AbstractPropertyTypeDescriptor &descriptor, PropertyStoragePtr &propertyStorage)
 Acquires a local value source entry that is free for the assignment of a value.
 
AbstractPropertyTypeDescriptor::ModifierStorageacquireModifierStorage (AbstractPropertyTypeDescriptor &descriptor, AbstractPropertyTypeDescriptor::PropertyStorage &propertyStorage)
 
AbstractPropertyTypeDescriptor::NotificationStorageacquireNotificationStorage (AbstractPropertyTypeDescriptor &descriptor)
 
PropertyStoragePtr acquirePropertyStorage (AbstractPropertyTypeDescriptor &descriptor)
 
template<typename DataType >
void addPropertyModifierBase (const PropertyType< DataType > &propertyType, typename PropertyType< DataType >::Descriptor::ModifierCallback callback, void *owner, bool notify)
 Adds a property modifier entry to the property modifier stack and validates them.
 
void addPropertyValueSource (AbstractPropertyTypeDescriptor &descriptor, AbstractPropertyTypeDescriptor::ValueSource *valueSource, PropertyValuePrecedence precedence, AbstractPropertyTypeDescriptor::ValueSourceOwner *owner)
 Internally adds a property value source.
 
void addPropertyValueSource (AbstractPropertyTypeDescriptor &descriptor, AbstractPropertyTypeDescriptor::ValueSource *valueSource, PropertyValuePrecedence precedence, void *ownerPointer)
 Internally adds a property value source.
 
AbstractPropertyTypeDescriptor::ValueSourceEntryconstructLocalValueSourceEntry (AbstractPropertyTypeDescriptor &descriptor, AbstractPropertyTypeDescriptor::PropertyStorage &propertyStorage)
 
PropertyStoragePtr constructPropertyStorage (AbstractPropertyTypeDescriptor &descriptor)
 
void copyLocalValue (const AbstractPropertyTypeDescriptor::PropertyStorage &otherPropertyStorage)
 Copy local value from property storage.
 
AbstractPropertyTypeDescriptor::ModifierStoragefindModifierStorage (AbstractPropertyTypeDescriptor &descriptor)
 
AbstractPropertyTypeDescriptor::NotificationStoragefindNotificationStorage (AbstractPropertyTypeDescriptor &descriptor) const
 
AbstractPropertyTypeDescriptor::PropertyStoragefindPropertyStorage (AbstractPropertyTypeDescriptor &descriptor) const
 Gets the property storage for given property type descriptor.
 
PropertyStoragePtr findPropertyStoragePtr (AbstractPropertyTypeDescriptor &descriptor) const
 Gets property storage intrusive pointer which you can use to hold a reference until the end of the operation.
 
AbstractPropertyTypeDescriptorfindPropertyTypeDescriptorByNameAndDataType (string_view name, PropertyDataType dataType) const
 Finds a property type descriptor by name and data type.
 
AbstractPropertyTypeDescriptorfindPropertyTypeDescriptorByQualifiedNameAndDataType (string_view qualifiedName, PropertyDataType dataType) const
 Like findPropertyTypeDescriptorByNameAndDataType, but only searches by matching with qualified names.
 
AbstractPropertyTypeDescriptorfindPropertyTypeDescriptorByUnqualifiedNameAndDataType (string_view unqualifiedName, PropertyDataType dataType) const
 Like findPropertyTypeDescriptorByNameAndDataType, but only searches by matching with unqualified names.
 
AbstractPropertyTypeDescriptor::ValueSourcegetClassValueSource (AbstractPropertyTypeDescriptor &descriptor) const
 
AbstractPropertyTypeDescriptor::ValueSourcegetFinalValueSource (AbstractPropertyTypeDescriptor &descriptor) const
 
AbstractPropertyTypeDescriptor::ValueSourcegetNonClassValueSource (AbstractPropertyTypeDescriptor &descriptor) const
 
AbstractPropertyTypeDescriptor::ValueSourcegetTopValueSource (AbstractPropertyTypeDescriptor &descriptor) const
 Gets the top-level value source for a given property descriptor.
 
void onCopy (const PropertyObject &other)
 
void removeLocalValue (AbstractPropertyTypeDescriptor &descriptor, PropertyStoragePtr &propertyStorage)
 Removes a local value from the given property storage.
 
void removePropertyValueSource (AbstractPropertyTypeDescriptor &descriptor, AbstractPropertyTypeDescriptor::ValueSource *valueSource, void *owner)
 Removes a property value source.
 
void validatePropertyModifiers (PropertyStoragePtr &propertyStorage)
 Validates property modifiers without notifying handlers.
 
void validatePropertyModifiersAndNotifyHandlers (PropertyStoragePtr &propertyStorage)
 Validates property modifiers and notifies handlers.
 
- Protected Member Functions inherited from kanzi::BindingHostConceptImpl< Node >
NodegetThisObject ()
 Internal accessor for the Curiously Recurring Template Pattern.
 
const NodegetThisObject () const
 Internal accessor for the Curiously Recurring Template Pattern.
 
- Protected Member Functions inherited from kanzi::BindingHostConcept
void attachBindings ()
 Attach all bindings stored in this object.
 
void detachBindings ()
 Detach bindings.
 

Protected Attributes

QuadDescription m_backgroundQuadDescription
 Background clipping quad / composition quad description.
 
NodeEffect2DSharedPtr m_cachedEffect
 Cached effect instance.
 
ClippingArea m_clipping
 Clipping parameters.
 
CompositionRequirements m_compositionRequirements
 Composition requirements for this 2D node.
 
unique_ptr< NodeCompositor2Dm_compositor
 Composition and caching information.
 
NodeEffectPrefab2DSharedPtr m_currentEffectPrefab
 Currently instantiated effect prefab.
 
optional< QuadDescriptionm_effectQuadDescription
 Effect quad description.
 
unsigned int m_validatedEffectPaddingChangeCounter
 Effect padding change counter value at which effect quad was last validated.
 
unique_ptr< NodeVisual2Dm_visual
 Visual information.
 
- Protected Attributes inherited from kanzi::Object
AppliedStyleContainer m_appliedStyles
 Listing of applied styles applied to this object.
 
- Protected Attributes inherited from kanzi::BindingHostConcept
BindingRuntimeContainer m_bindingRuntimes
 Bindings in this object.
 

Friends

void doListBoxArrange (Node2D &node)
 
class Screen
 
class Viewport3D
 

Properties

static PropertyType< floatAspectRatioProperty
 AspectRatio property.
 
static PropertyType< boolForceCompositionProperty
 ForceComposition property.
 
static PropertyType< Node2D::ForegroundHintForegroundHintProperty
 ForegroundHint property.
 
static PropertyType< boolOffscreenRenderingProperty
 OffscreenRendering property.
 
static PropertyType< boolDisableRenderTargetClearProperty
 DisableRenderTargetClear property.
 
static PropertyType< Node2D::PixelFormatPixelFormatProperty
 PixelFormat property.
 
static PropertyType< boolRenderSelfProperty
 RenderSelf property.
 
static PropertyType< ResourceSharedPtrRenderTargetProperty
 RenderTarget property.
 
static PropertyType< floatRenderTargetMinimumHeightProperty
 RenderTargetMinimumHeight property.
 
static PropertyType< floatRenderTargetMinimumWidthProperty
 RenderTargetMinimumWidth property.
 
static PropertyType< floatRenderTargetReallocationLimitProperty
 RenderTargetReallocationLimit property.
 
static PropertyType< CachingModeCachingModeProperty
 Sets the caching mode:
 
static PropertyType< boolCacheValidProperty
 Kanzi sets the value of this property to indicate whether the node is cached.
 
static PropertyType< SRTValue2DLayoutTransformationProperty
 Sets the layout transformation of the node.
 
static PropertyType< SRTValue2DRenderTransformationProperty
 Sets the render transformation of the node.
 
static PropertyType< SRTValue3DPerspectiveTransformationProperty
 Sets the perspective transformation of the node.
 
static PropertyType< PerspectiveTransformationModePerspectiveTransformationModeProperty
 Sets the perspective transformation mode of the node.
 
static PropertyType< floatPerspectiveTransformationFovProperty
 PerspectiveTransformationFov property.
 
static PropertyType< Vector3PerspectiveTransformationPivotProperty
 PerspectiveTransformationOrigin property.
 
static PropertyType< Vector3PerspectiveTransformationOriginProperty
 PerspectiveTransformationOrigin property.
 
static PropertyType< Vector2RenderTransformationOriginProperty
 RenderTransformationOrigin property.
 
static PropertyType< boolSnapToPixelProperty
 SnapToPixel property.
 
static PropertyType< ResourceSharedPtrBackgroundBrushProperty
 BackgroundBrush property.
 
static PropertyType< ResourceSharedPtrCompositionBrushProperty
 CompositionBrush property.
 
static PropertyType< ResourceSharedPtrForegroundBrushProperty
 ForegroundBrush property.
 
static PropertyType< ResourceSharedPtrEffectProperty
 Reports the runtime effect instance used by the node, instantiated from the NodeEffectPrefab2D.
 
static PropertyType< ResourceSharedPtrEffectPrefabProperty
 Sets the 2D Effect prefab to use for the node.
 
static PropertyType< MultisampleCountMultisampleLevelProperty
 Sets the number of anti-aliasing samples to use for temporary composition targets.
 
float getAspectRatio () const
 Gets the value of AspectRatioProperty.
 
void setAspectRatio (float value)
 Sets the value of AspectRatioProperty.
 
bool isForceComposition () const
 Gets the value of ForceCompositionProperty.
 
void setForceComposition (bool value)
 Sets the value of ForceCompositionProperty.
 
Node2D::ForegroundHint getForegroundHint () const
 Gets the value of ForegroundHintProperty.
 
void setForegroundHint (Node2D::ForegroundHint value)
 Sets the value of ForegroundHintProperty.
 
bool isOffscreenRendering () const
 Gets the value of OffscreenRenderingProperty.
 
void setOffscreenRendering (bool value)
 Sets the value of OffscreenRenderingProperty.
 
bool isDisableRenderTargetClear () const
 Gets the value of DisableRenderTargetClearProperty.
 
void setDisableRenderTargetClear (bool value)
 Sets the value of DisableRenderTargetClearProperty.
 
Node2D::PixelFormat getPixelFormat () const
 Gets the value of PixelFormatProperty.
 
void setPixelFormat (Node2D::PixelFormat value)
 Sets the value of PixelFormatProperty.
 
bool isRenderSelf () const
 Gets the value of RenderSelfProperty.
 
void setRenderSelf (bool value)
 Sets the value of RenderSelfProperty.
 
float getRenderTargetMinimumHeight () const
 Gets the value of RenderTargetMinimumHeightProperty.
 
void setRenderTargetMinimumHeight (float value)
 Sets the value of RenderTargetMinimumHeightProperty.
 
float getRenderTargetMinimumWidth () const
 Gets the value of RenderTargetMinimumWidthProperty.
 
void setRenderTargetMinimumWidth (float value)
 Sets the value of RenderTargetMinimumWidthProperty.
 
float getRenderTargetReallocationLimit () const
 Gets the value of RenderTargetReallocationLimitProperty.
 
void setRenderTargetReallocationLimit (float value)
 Sets the value of RenderTargetReallocationLimitProperty.
 
CachingMode getCachingMode () const
 Gets the value of CachingModeProperty.
 
void setCachingMode (CachingMode value)
 Sets the value of CachingModeProperty.
 
SRTValue3D getPerspectiveTransformation () const
 Gets the value of PerspectiveTransformationProperty.
 
void setPerspectiveTransformation (SRTValue3D value)
 Sets the value of PerspectiveTransformationProperty.
 
PerspectiveTransformationMode getPerspectiveTransformationMode () const
 Gets the value of PerspectiveTransformationModeProperty.
 
void setPerspectiveTransformationMode (PerspectiveTransformationMode value)
 Sets the value of PerspectiveTransformationModeProperty.
 
float getPerspectiveTransformationFov () const
 Gets the value of PerspectiveTransformationFovProperty.
 
void setPerspectiveTransformationFov (float value)
 Sets the value of PerspectiveTransformationProperty.
 
Vector3 getPerspectiveTransformationPivot () const
 Gets the value of PerspectiveTransformationPivotProperty.
 
void setPerspectiveTransformationPivot (Vector3 value)
 Sets the value of PerspectiveTransformationPivotProperty.
 
Vector3 getPerspectiveTransformationOrigin () const
 Gets the value of PerspectiveTransformationOriginProperty.
 
void setPerspectiveTransformationOrigin (Vector3 value)
 Sets the value of PerspectiveTransformationOriginProperty.
 
Vector2 getRenderTransformationOrigin () const
 Gets the value of RenderTransformationOriginProperty.
 
void setRenderTransformationOrigin (Vector2 value)
 Sets the value of RenderTransformationOriginProperty.
 
bool isSnapToPixel () const
 Gets the value of SnapToPixelProperty.
 
void setSnapToPixel (bool value)
 Sets the value of SnapToPixelProperty.
 
MultisampleCount getMultisampleLevel () const
 Gets the value of MultisampleLevelProperty.
 
void setMultisampleLevel (MultisampleCount value)
 Sets the value of MultisampleLevelProperty.
 

Additional Inherited Members

- Static Public Attributes inherited from kanzi::Node
static PropertyType< string > NameProperty
 Name property.
 
static PropertyType< string > PathProperty
 Path property.
 
static PropertyType< string > LocaleProperty
 Locale property.
 
static PropertyType< boolCreatedFromKZBProperty
 CreatedFromKZB property.
 
static PropertyType< boolHitTestableProperty
 HitTestable property.
 
static PropertyType< boolHitTestableContainerProperty
 HitTestableContainer property.
 
static PropertyType< boolVisibleProperty
 Visible property.
 
static PropertyType< boolEnabledProperty
 Sets whether the node is enabled.
 
static PropertyType< boolEffectivelyEnabledProperty
 Indicates whether the node and its ancestor nodes are enabled.
 
static PropertyType< boolFocusableProperty
 Sets whether a node can get focus and can participate in the focus chain navigation.
 
static PropertyType< boolFocusedProperty
 Sets whether a node is an focus node and can receive key messages.
 
static PropertyType< FocusStateFocusStateProperty
 Reports the focus state of a focusable node or focus scope node.
 
static PropertyType< ResourceSharedPtrFontFamilyProperty
 Sets the font family the node uses.
 
static PropertyType< floatVisibleAmountInParentProperty
 VisibleAmountInParent property.
 
static PropertyType< floatProjection2DTo3DScaleProperty
 Projection2DTo3DScale property.
 
static PropertyType< ResourceSharedPtrStyleProperty
 Style property.
 
static PropertyType< ResourceSharedPtrStateManagerProperty
 StateManager property.
 
static PropertyType< void * > PrefabTemplateSourceProperty
 PrefabTemplateSource property.
 
static PropertyType< floatWidthProperty
 Width property.
 
static PropertyType< floatHeightProperty
 Height property.
 
static PropertyType< floatDepthProperty
 Depth property.
 
static PropertyType< floatActualWidthProperty
 ActualWidth property.
 
static PropertyType< floatActualHeightProperty
 ActualHeight property.
 
static PropertyType< floatActualDepthProperty
 ActualDepth property.
 
static PropertyType< Node::HorizontalAlignmentHorizontalAlignmentProperty
 HorizontalAlignment property.
 
static PropertyType< Node::VerticalAlignmentVerticalAlignmentProperty
 VerticalAlignment property.
 
static PropertyType< Node::DepthAlignmentDepthAlignmentProperty
 DepthAlignment property.
 
static PropertyType< Vector2HorizontalMarginProperty
 Sets the horizontal space between this node and other nodes that are adjacent to this node in a layout.
 
static PropertyType< Vector2VerticalMarginProperty
 Sets the vertical space between this node and other nodes that are adjacent to this node in a layout.
 
static PropertyType< Vector2DepthMarginProperty
 Sets the space in the depth direction between this node and other nodes that are adjacent to this node in a layout.
 
static PropertyType< Node::ContentStretchContentStretchProperty
 ContentStretch property.
 
static PropertyType< floatOpacityProperty
 Opacity property.
 
static PropertyType< boolHoverProperty
 Kanzi updates the HoverProperty for a hit testable node to indicate whether the node is the foremost node under the cursor.
 
static PropertyType< boolClipChildrenProperty
 ClipChildren property.
 
static PropertyType< intSceneGraphAddNodeChangeChildFlagsProperty
 SceneGraphAddNodeChangeChildFlags property.
 
static PropertyType< intSceneGraphAddNodeChangeParentFlagsProperty
 SceneGraphAddNodeChangeParentFlags property.
 
static PropertyType< intSceneGraphRemoveNodeChangeChildFlagsProperty
 SceneGraphRemoveNodeChangeChildFlags property.
 
static PropertyType< intSceneGraphRemoveNodeChangeParentFlagsProperty
 SceneGraphRemoveNodeChangeParentFlags property.
 
- Static Protected Member Functions inherited from kanzi::Node
static VisitorResult applyStylesVisitor (Node &node, bool apply)
 
static VisitorResult attachVisitor (Node &node)
 
static VisitorResult detachVisitor (Node &node)
 
static bool processPropertyChanged (Node &node, AbstractPropertyType propertyType, const PropertyStoragePtr &nodePropertyStorage, AbstractPropertyTypeDescriptor::PropertyStorage *changedPropertyStorage, PropertyNotificationReason reason)
 Processes notification handlers for node and property storage.
 
static VisitorResult propertyChangedVisitor (Node &node, AbstractPropertyType propertyType, AbstractPropertyTypeDescriptor::PropertyStorage *propertyStorage, PropertyNotificationReason reason)
 
static VisitorResult updateAllResourcesVisitor (Node &node)
 
static VisitorResult updateResourceVisitor (Node &node, const ResourceID &id)
 
static VisitorResult validateDrawVisitor (Node &node)
 Visitor for validating draw.
 

Detailed Description

Node2D is the base class of 2D nodes.

Node2D implements functionality common to all 2D nodes, such as rendering, layouting, and hit testing.

To create UI graphs, use classes derived from Node2D, such as Image2D, EmptyNode2D, and StackLayout2D. To implement your own custom rendering and layout, derive from Node2D.

You can use methods of the Node2D class to configure common parameters for rendering and layout. Use methods of the derived classes to control behavior specific to them.

Creating nodes

To create a 2D node, call a create function that returns a shared pointer to the node.

To create an EmptyNode2D node:

To create an Image2D node:

Each node has its own type of create function.

The constructors of nodes are protected, and can be accessed only by the inheriting classes. Node initialization happens within the create function, after constructing the node.

Node tree

Kanzi arranges nodes in a tree that you can think of as a directed acyclic graph with no loops. Each node can have multiple children but only one parent.

The root node of the node tree is always a 2D node. The root node does not have a parent, and it is usually of type Screen.

The Viewport2D node serves as a window to a 3D scene graph that Kanzi displays in the viewport area. A Viewport2D node must have a child Scene node as the root of the 3D scene graph. The child nodes of the Scene node are Node3D nodes.

Constructing the node tree

You can manipulate the node tree by adding children to nodes:

// Create and add a child node.
Node2DSharedPtr childNode = EmptyNode2D::create(domain, "child");
parentNode->addChild(childNode);

You can remove children from a parent node:

Parents take ownership, and hold a reference to the children.

Iterating the node tree

You can explore the node tree from a node by iterating its children:

for (Node2D::ChildConstIterator it = parentNode->beginChildren(); (it != parentNode->endChildren()); ++it)
{
// Get the name from current child and do something with it as an example.
stream << (*it)->getName() << "::";
}

You can also go upwards to the parent:

// Node2D will always have a parent of type Node2D.
Node2D* parent = dynamic_cast<Node2D*>(child1->getParent());

The parent returned is valid except for the root node that has no parent (it returns nullptr).

Finding nodes

Finding nodes in the node tree is inherited from Node base class. You can look for nodes with a path:

// "parent" is a child of screen.
Node2DSharedPtr foundChild = screen->lookupNode<Node2D>("parent/child1");

The paths work relative from the node doing the lookup. You can also traverse upwards:

// "child1" is a child of "parent", which is a child of screen.
Node2DSharedPtr foundScreen = child1->lookupNode<Node2D>("../..");

If lookup fails, no node is returned. See node tree lookup in Node documentation.

Rendering

Kanzi renders nodes starting from the root node of the node tree, iterating the tree in depth-first algorithm.

A 2D node has a foreground and a background. Kanzi renders the foreground and background separately. Node classes can override the foreground or background rendering separately.

Foreground is the content of the node. For example, an image.

Background is the full node area. The background can be of the same size as the node content, or larger.

To fit the content to the node area, use the ContentStretchProperty.

Rendering order

Kanzi renders nodes in the order in which you add the nodes to the parent node. The node that you add first is rendered first.

You can modify the rendering order by reordering the child nodes within a parent node.

To render a node last, move that node to the front:

// child1 will now be rendered last, after other children of the parent.
child3->moveToFront();

To render a node first, move that node to the back:

// child3 will now be rendered first before other children of the parent.
child3->moveToBack();

Kanzi always renders the content of a parent node before rendering its child nodes.

Using brushes

Kanzi uses brushes to render the foreground, background, and the optional composition of a node. Brushes determine how Kanzi does the rendering. A brush can display a color or an image, tint content provided by the node, or use an arbitrary shader to render the content of a node.

A 2D node can have a foreground brush, background brush, and a composition brush. Use the ForegroundBrushProperty, BackgroundBrushProperty, and CompositionBrushProperty to access the brushes.

To set the foreground brush of a 2D node:

textNode->setForegroundBrush(ColorBrush::create(domain, "color brush", ColorRGBA(0.5f, 1.0f, 0.5f, 1.0f)));

Use the foreground brush to render the content that the node provides. For example, an Image2D node provides an image. If a node does not provide foreground content, setting the foreground brush has no effect. Most 2D nodes render on top of the background an empty foreground of the same size as the background. For example, the EmptyNode2D node.

To set the background brush of a 2D node:

// Set color brush to draw the background of an empty brush.
empty->setBackgroundBrush(ColorBrush::create(domain, "color brush", ColorRGBA(0.8f, 1.0f, 0.2f, 1.0f)));

Use the background brush to render the content outside and behind the node foreground area. If the node has no foreground or the foreground is translucent, the background fills the entire node area. If the foreground is opaque and fills the entire node area, Kanzi does not render the background.

To disable rendering, set null brush:

// Disable rendering of foreground by setting a null brush.
image->setForegroundBrush(Brush::acquireNullBrush(*image->getResourceManager()));

Note that some node types have default brushes, which is why removing the brush property is not enough to disable rendering. Instead, Kanzi renders the node using the default brush.

Opacity

To control the translucency of a node, use the OpacityProperty. You can set the opacity of a node:

// Set image to blend halfway between the background and the image.
image->setOpacity(0.5f);

Opacity affects node background, foreground, and all node children.

When the brushes or content of a 2D node are translucent, the foreground and background of that node can be translucent even when you do not set the OpacityProperty.

Setting a 2D node as translucent affects all children of that node. To render overlapping translucency in the child nodes correctly, it is possible that you have to composite the parent node. See Composition.

Render transformation

To set the rendering position of a node relative to its parent, use the RenderTransformationProperty:

// Rotate node ~90 degrees counter-clockwise and translate it 50 units to the right.
node->setRenderTransformation(SRTValue2D(Vector2(1.0f, 1.0f), -1.570796f, Vector2(50.0f, 0.0f)));

Kanzi specifies the render transformation as SRT, that is, Scale, Rotation, and Translation.

By default, Kanzi performs the render transformation of a 2D node relative to the top-left corner of that node. To set the origin of the render transformation within the node, use the RenderTransformationOriginProperty:

// Set node to rotate around its center point as opposed to top left corner.
node->setRenderTransformationOrigin(Vector2(0.5f, 0.5f));

You can also set the render transformation origin outside the node:

// Set node to rotate around point that's on the node area bottom but three times its width to the left.
node->setRenderTransformationOrigin(Vector2(-3.0f, 1.0f));

The values set to render transform origin are relative to the size of the node. For example, the value 0.5 ; 0.5 sets the origin at the center of the node.

Kanzi applies the render transformation after applying layout transformation. Render transformation is not affected by layout constraints such as alignment and margins, and does not modify the size layout nodes take into account. See Layout transformation.

Perspective transformation

To bring limited 3D effects to a 2D node tree, you can apply perspective transformation in 3D space. Perspective transformation is an optional transformation that Kanzi applies as the last Node2D transformation, after the layout and render transformations.

To set the perspective transformation:

// Rotate 2D node slightly over the Y axis to give it perspective.
node->setPerspectiveTransformation(SRTValue3D(Vector3(1.0f, 1.0f, 1.0f), Vector3(0.0f, 0.2f, 0.0f), Vector3(0.0f, 0.0f, 0.0f)));

Kanzi applies the projection for perspective transformation in the space of the current composition space. Kanzi specifies the perspective transformation as 3D SRT, that is, 3-component Scale, Rotation, and Translation vectors.

NodeVisual2D

Kanzi stores in an object of type NodeVisual2D all information related to the foreground and background rendering in Node2D. NodeVisual2D holds the brush and geometry information that Kanzi needs to render 2D node. To save memory, if node has nothing to render, Kanzi does not allocate a visual component.

Once the visual component is allocated, Node2D never releases it.

Composition

By default, Kanzi renders a 2D node into the rendering context of the parent node. Usually, the top-level rendering context is the backbuffer, provided by the Screen node.

You can manually override this and render a node into a render target:

// Set a render target to render the empty node in.
emptyNode->setRenderTarget(renderTarget);

When you specify the render target, the node takes its size from the render target size. You can define fixed width and fixed height for a node that also has a render target set. The fixed size can be smaller than the size of the render target. In this case, rendering happens only on a part of the render target area. Specifying a fixed size larger than the render target size is undefined behavior. A node that Kanzi renders into a render target also draws the resulting composition to the rendering context of their parent.

To achieve the correct rendering result, in some cases, Kanzi automatically renders nodes using a render target.

If the opacity of a Viewport2D is not 1.0 or if its transformation has non-translation components, that Viewport2D renders to a render target:

// Rotate viewport node 0.2 radians counter-clockwise.
// The viewport will need to be composited.
viewportNode->setRenderTransformation(SRTValue2D(Vector2(1.0f, 1.0f), 0.2f, Vector2(0.0f, 0.0f)));
// Returns true.
bool isInCompositionTarget = viewportNode->isSelfInCompositionTarget();

Viewport2D is a 'window' to a 3D scene. It must be aligned to the units in the parent render context. If this is not the case, it needs to be composited.

All nodes render to render targets if they have children and their opacity is not one:

// Add an child to a parent node.
parentNode->addChild(childNode);
// Make the parent translucent.
// The parent will need a composition target to ensure correct rendering result.
parentNode->setOpacity(0.8f);
// Returns true.
bool isInCompositionTarget = parentNode->isSelfInCompositionTarget();

The parent has opacity set, so it will first need to do composition of all its children, and then render this composition using that opacity.

When you assign a render target manually, you can set that render target to take its size from the size of the node. In this case, Kanzi resizes the composition target to the size that the node gets during layout:

// This example shows how to create a Texture and use it as a render target for a 2D node.
//
// Kanzi determines the size of the render target automatically from the size of the 2D node
// and renders the node:
// - To texture as specified with Node2D::setRenderTarget().
// - Only to texture as specified with Node2D::setOffscreenRendering().
//
// \see Node2D::RenderTargetProperty
// \see Node2D::OffscreenRenderingProperty
// \see Texture::CreateInfoNode2DRenderTarget
// \see Texture::create()
// Create a node tree.
ScreenSharedPtr screen = Screen::create(domain, "screen");
screen->attach();
// Create a node.
// Set a size to the node to determine the size that Kanzi uses to set the size of the render target.
EmptyNode2DSharedPtr node = EmptyNode2D::create(domain, "node");
node->setWidth(static_cast<float>(width));
node->setHeight(static_cast<float>(height));
screen->addChild(node);
// Create a background brush for the node.
ColorBrushSharedPtr brush = ColorBrush::create(domain, "brush", ColorRGBA(0.4f, 0.4f, 0.9f, 1.0f));
node->setBackgroundBrush(brush);
// Create a render target texture for the node.
// To create a texture with the same size as the node to which you assign it, set width divisor and height divisor to 1.
Texture::CreateInfoNode2DRenderTarget textureCreateInfo(1, 1, GraphicsFormatR8G8B8A8_UNORM);
textureCreateInfo.widthDivisor = 1;
textureCreateInfo.heightDivisor = 1;
TextureSharedPtr renderTarget = Texture::create(domain, textureCreateInfo, "texture");
node->setRenderTarget(renderTarget);
// Render only to render target texture.
node->setOffscreenRendering(true);
// Render the node tree.
{
CompositionStack& compositionStack = renderer->getCompositionStack();
screen->setAllocatedSize(Vector2(static_cast<float>(width), static_cast<float>(height)));
screen->setArrangeTransform(Matrix3x3());
screen->layout();
compositionStack.pushComposition(0, screen->getAllocatedSize());
screen->render(*renderer, compositionStack);
compositionStack.popComposition();
}
screen->detach();

Offscreen rendering

Nodes do not necessarily have to draw their composition onto the render context of their parent. To enable offscreen rendering:

// Turn on offscreen rendering.
// The node will be rendered into its render target, but not blit onto the parent render context.
emptyNode->setOffscreenRendering(true);

When you enable offscreen rendering, Kanzi does not draw the node anywhere after rendering to its render target.

You can render the render target of the node using some other node:

// Set image to use the render target previously set on the empty node.
imageNode->setImage(emptyNode->getRenderTarget());

The render target behaves like a normal texture when used. Setting the render target to an Image2D determines its size unless you set the render target to use fixed size.

Clearing a render target

When Kanzi renders a Node2D to a render target, it clears the color and depth buffers of that render target. If the render target has a depth buffer, and the node is not a Viewport2D that clears it in a RenderPass, Kanzi clears the depth buffer. If the foreground of the node does not fill the complete composition area, or the combination of background and foreground is translucent, Kanzi clears the color buffer.

To disable the clearing of a render target:

// Disable clearing of render target even if it would otherwise be done.
emptyNode->setDisableRenderTargetClear(true);

When you disable the clearing of a render target, you prevent the node from clearing the render target even if the node would otherwise do it.

By default, Kanzi clears all render targets. This simplifies the rendering code and increases performance on GPUs that use tiled renderers.

Caching

To avoid rendering a 2D node and its descendants every frame, you can cache the rendering results of a 2D node. Caching carries a cost in GPU memory. Cache only complex nodes that are expensive to render and change rarely. You can either:

  • Let Kanzi update the cache automatically whenever the node or any of its descendants change.
  • Make Kanzi use the same cache until you manually invalidate that cache.

To control the caching of a 2D node, use the CachingModeProperty. You can enable or disable the cache:

// Enable caching of node content and of all its descendants.
parentNode->setCachingMode(CachingModeEnabled);

When the CachingModeProperty is set to CachingModeEnabled, the node content does not change until you either:

To invalidate the cache:

// Force redraw of node content.
parentNode->resetCache();

After you invalidate the cache, Kanzi renders the node content once. After this, Kanzi considers the node cached again. You can disable the cache:

// Disable caching of the node and all its descendants.
parentNode->setCachingMode(CachingModeDisabled);

After you disable the cache, Kanzi renders the node normally and all changes to the node and its descendants are visible immediately.

Setting the CachingModeProperty to CachingModeAutomatic causes Kanzi to automatically update the cache of the node whenever the content of the node or its descendants change. To set Kanzi to automatically update the cache:

// Set caching mode to automatic.
parentNode->setCachingMode(CachingModeAutomatic);

When the caching mode is set to automatic, any change to the node or its descendants causes Kanzi to update the cache. You can manually set the draw flag on a child node to invalidate the cache:

// Setting any property that invalidates the draw flag causes Kanzi to update the cache of the parent node.
imageChildNode->setOpacity(1.0f);

Setting any property that controls rendering will eventually invalidate draw.

NodeCompositor2D

Kanzi stores in NodeCompositor2D all information related to compositing. This object holds composition targets, caching information, and a composition brush. Because compositing implies rendering, it is not possible to allocate a compositor without also allocating a NodeVisual2D. To save memory, if composition is not needed, Kanzi does not allocate a compositor component.

Once the compositor component is allocated, Node2D never releases it. Composition targets within compositor can be released if not needed.

Basic Layout

A 2D node tries to determine its size automatically. A 2D node with content by default takes the size of its content. For example, Image2D takes the size of the image that it displays. EmptyNode2D and Viewport2D have unbounded layout by default. This means that they take the entire available size. Kanzi calculates the available size from the size of the parent node, or the available screen area. To arrange nodes in a layout, use layout control nodes such as StackLayout2D or GridLayout2D.

To set the size of a 2D node:

// Set width to 160 units and height to 90 units.
node->setWidth(160.0f);
node->setHeight(90.0f);

To set a 2D node to determine its size automatically, remove the fixed size:

// Set width and height to be determined automatically.
node->setAutoWidth();
node->setAutoHeight();

or:

// Set width and height to be determined automatically.
node->setAutoSize();

You can configure a node to take its width or height based on a specified fixed size and an aspect ratio:

// Sets node aspect ratio to ~16:9.
node->setAspectRatio(1.777778f);

If fixed width and aspect ratio are defined, height is width divided by aspect ratio. If fixed height and aspect ratio are defined, width is height multiplied by aspect ratio. If both fixed width and fixed height are defined, aspect ratio has no effect.

If neither width or height are defined, but aspect ratio is defined, the result depends on the node. A node that has unbounded layout takes the largest size it can with the given aspect ratio while still fitting within its allocated size. Aspect ratio has no effect when the content of a node defines its size. This is analogous to having both fixed width and fixed height.

A 2D node has an allocated area specified by the area of the parent node or a layout node. You can configure a 2D node to align in its allocated area by setting horizontal and vertical alignment:

// Align node to right bottom corner of its parent.
node->setHorizontalAlignment(Node::HorizontalAlignmentRight);
node->setVerticalAlignment(Node::VerticalAlignmentBottom);

Available values for horizontal alignment are:

Available values for vertical alignment are:

You can configure 2D node to fill its allocated area by setting alignment to stretch:

// Set node to fill the area of its parent.
node->setHorizontalAlignment(Node::HorizontalAlignmentStretch);
node->setVerticalAlignment(Node::VerticalAlignmentStretch);

You can offset a 2D node from the edges of its parent node:

// Offset node 20 units from left and top edges and 10 units from right and bottom edges of its parent.
node->setHorizontalMargin(Vector2(20.0f, 10.0f));
node->setVerticalMargin(Vector2(20.0f, 10.0f));

For horizontal margins, the order of values is left, then right. For vertical margins, the order of values is top, then bottom. Kanzi offsets the node from the edge of its allocated area by the amount equal to the margin that you set. When you do not set the margins, Kanzi aligns the node at the edge of allocated area.

Layout transformation

To set the transformation of a node relative to its parent node, set the LayoutTransformationProperty:

// Rotate node ~45 degrees clockwise.
node->setLayoutTransformation(SRTValue2D(Vector2(1.0f, 1.0f), 0.7853982f, Vector2(0.0f, 0.0f)));

Kanzi specifies the layout transform as SRT, that is, Scale, Rotation, and Translation.

When you transform a node with layout transformation, Kanzi applies alignment and margins to that node after the transformation. Kanzi applies render transformation after layout transformation, alignment, and margins.

See Render transformation and Perspective transformation.

Content stretch

The foreground content, such as an image, of a 2D node, has rules on how to stretch in relation to the node area.

These are the available content stretch modes:

  • ContentStretchNone centers the foreground area in the node area and keeps the exact size of the content.

    If the node is smaller than the foreground area, it displays only a part of the content.

    If the node is larger than the foreground area, the remaining area is left for background rendering.

  • ContentStretchFill sets the foreground area to take the exact node area.

    This can change the aspect ratio of the content.

  • ContentStretchUniform sets the foreground content to stretch to fill the node area while keeping its aspect ratio.

    If the aspect ratio of the node is different from content aspect ratio, the remaining area is left for background rendering.

    This is the default content stretch mode.

  • ContentStretchUniformToFill centers the foreground area relative to the node area and scales the foreground uniformly to fill the node area.

    If the aspect ratio of the node is different from the content aspect ratio, the node displays only part of the content.

To set the content stretch mode:

image->setContentStretch(Node::ContentStretchFill);

Layout in main loop

During the main loop of the application, Kanzi calls layout for the root node. Before calling layout, Kanzi sets the allocated size of the Screen node to the size of the current graphics output. The layout pass evaluates only nodes that are marked as requiring layout. Kanzi calls render immediately after layout.

Because Kanzi calls render immediately after layout, you can modify the node tree and see the changes before the next call to the update function. It can be useful to determine the calculated sizes or locations of nodes before waiting for the next frame. To call layout manually:

// Add node to screen.
screen->addChild(node);
// To determine node actual size, must call layout.
// Before calling layout, must set allocated size of screen.
screen->setAllocatedSize(Vector2(1280.0f, 720.0f));
screen->layout();

After calling layout(), you can call getActualSize() to get the size determined by the node. Default allocated size is unbounded layout or infinity. When calling layout() manually, you must set the allocated size for the node that receives the layout() call.

See Implementing a custom 2D node - Layout.

Hit testing

You can hit test nodes in regard to their location on screen:

// Create an image nodes and add it to the parent node.
TextureSharedPtr texture = Texture::create(domain, Texture::CreateInfo2D(10, 10, GraphicsFormatR8G8B8_UNORM), "Example texture");
Image2DSharedPtr childNode = Image2D::create(domain, "child", texture);
parentNode->addChild(childNode);
// Align image to bottom right of parent.
parentNode->setWidth(400.0f);
parentNode->setHeight(300.0f);
childNode->setHorizontalAlignment(Node2D::HorizontalAlignmentRight);
childNode->setVerticalAlignment(Node2D::VerticalAlignmentBottom);
screen->layout();
// Parent is of size 400, 300, so 395, 295 will hit inside a child of size 10, 10.
NodeSharedPtr node = screen->hitTest(Vector2(395.0f, 295.0f));

Hit testing uses the 'world' or 'render' coordinates of the node. These coordinates are relative to the screen, not to the parent node or to the node that does the hit testing. Hit testing takes into account the visibility and all transformations of a node.

Hit testing transforms global coordinates into Node2D local coordinates to determine if the node is hit. You can determine world (screen) space coordinates in the local coordinate space of a 2D node:

The return value is enclosed in an optional value, but is always valid if the node has a real nondegenerate transformation.

You can test whether given coordinates hit a node:

Checking whether a global coordinate is within a node is equal to calling globalToLocal() and then testing the result with containsLocal().

Implementing a custom 2D node

To do custom rendering and layout, you can implement a custom 2D node.

Defining the class

To define a custom Node2D implementation, inherit from the Node2D base class.

To define a Node2D implementation:

class ExampleNode2D;
typedef shared_ptr<ExampleNode2D> ExampleNode2DSharedPtr;
class ExampleNode2D : public kanzi::Node2D
{
public:
static PropertyType<float> ExampleProperty;
float getExampleProperty() const
{
return getProperty(ExampleProperty);
}
void setExampleProperty(float value)
{
setProperty(ExampleProperty, value);
}
KZ_METACLASS_BEGIN(ExampleNode2D, Node2D, "MyNamespace.ExampleNode2D")
KZ_METACLASS_PROPERTY_TYPE(ExampleProperty)
class ExampleMessageArguments : public MessageArguments
{
public:
static PropertyType<bool> ExampleArgumentProperty;
KZ_MESSAGE_ARGUMENTS_METACLASS_BEGIN(ExampleMessageArguments, MessageArguments, "MyNamespace.ExampleNode2D.ExampleMessageArguments")
KZ_METACLASS_PROPERTY_TYPE(ExampleArgumentProperty)
static PropertyTypeEditorInfoSharedPtr makeEditorInfo();
};
static MessageType<ExampleMessageArguments> ExampleMessage;
static ExampleNode2DSharedPtr create(Domain* domain, string_view name);
protected:
explicit ExampleNode2D(Domain* domain, string_view name);
void initialize();
Vector2 measureOverride(Vector2 availableSize) override;
void updateRenderOverride() override;
void onExampleMessage(ExampleMessageArguments& arguments);
private:
ClassPropertyDefaultValue<float> m_classValueExampleProperty;
};

The next sections explain different parts of the node declaration.

Metaclass

Each class derived from Node2D must have a metaclass definition. To declare the metaclass, inherit from the Node2D base class and list the properties specific to the inherited node:

KZ_METACLASS_BEGIN(ExampleNode2D, Node2D, "MyNamespace.ExampleNode2D")
KZ_METACLASS_PROPERTY_TYPE(ExampleProperty)

For details about metaclass, see the description in Node documentation.

Property types

Local property types are declared in metaclass to belong to the node. Additionally, property types must be declared within the node:

static PropertyType<float> ExampleProperty;

It is also often useful to declare setters and getters to wrap getProperty() and setProperty() for the custom property.

float getExampleProperty() const
{
return getProperty(ExampleProperty);
}
void setExampleProperty(float value)
{
setProperty(ExampleProperty, value);
}

After declaring a property type in the class, you must add the property definition. The definition lists property metadata. The example property is defined as follows:

PropertyType<float> ExampleNode2D::ExampleProperty(kzMakeFixedString("ExampleNode2D.Example"), 1.0f, PropertyTypeChangeFlagFinalTransformation, false,
(
metadata.displayName = "Example property";
metadata.tooltip = "Property used as example.";
metadata.host = "Node:user, Node2D:context, Material:user";
metadata.lowerBound = "0.0";
metadata.upperBound = "1.0";
metadata.step = "0.01";
));

Note that the property has the PropertyTypeChangeFlagFinalTransformation flag set. This means that updateRender must be called for the node when the property value changes.

These property change flags determine what Kanzi has to recalculate when the property value changes.

Nodes can have class values for properties:

ClassPropertyDefaultValue<float> m_classValueExampleProperty;

A class value overrides the default value that the node otherwise has for a property, but the value applies only to objects of a certain class.

For more information about properties in nodes, see the documentation of the Node class.

Message types

To communicate with each other, Kanzi nodes send messages.

Declare the message types in the node:

class ExampleMessageArguments : public MessageArguments
{
public:
static PropertyType<bool> ExampleArgumentProperty;
KZ_MESSAGE_ARGUMENTS_METACLASS_BEGIN(ExampleMessageArguments, MessageArguments, "MyNamespace.ExampleNode2D.ExampleMessageArguments")
KZ_METACLASS_PROPERTY_TYPE(ExampleArgumentProperty)
static PropertyTypeEditorInfoSharedPtr makeEditorInfo();
};
static MessageType<ExampleMessageArguments> ExampleMessage;

Like the node itself, the message class must define a metaclass and properties.

You must also define the message type, metadata, and related property metadata:

PropertyType<bool> ExampleNode2D::ExampleMessageArguments::ExampleArgumentProperty(kzMakeFixedString("MessageArgument.ExampleNode2D.Example"), false, 0, false,
(
metadata.displayName = "Example argument";
metadata.tooltip = "Example message argument property";
));
PropertyTypeEditorInfoSharedPtr ExampleNode2D::ExampleMessageArguments::makeEditorInfo()
{
metadata.displayName = "Example message";
metadata.tooltip = "Example definition of a message that can be listened.";
));
}
MessageType<ExampleNode2D::ExampleMessageArguments> ExampleNode2D::ExampleMessage(kzMakeFixedString("Message.ExampleNode2D.Example"), nullptr);

The argument definition is similar to property type definition. You also need to define the message type and metadata for Kanzi Studio.

A node can subscribe to listen to any messages. Typically this happens on initialization.

For more information about messages, see the documentation of the Node class.

Initialize pattern

Constructing a node initializes node-specific values and passes them to the base class constructor.

ExampleNode2D::ExampleNode2D(Domain* domain, string_view name) :
Node2D(domain, name),
m_classValueExampleProperty(*this, ExampleProperty, 0.5f)
{
}

Class values are initialized in the constructor.

Further initialization is done in Node::initialize(), that is called from the create function:

ExampleNode2DSharedPtr ExampleNode2D::create(Domain* domain, string_view name)
{
ExampleNode2DSharedPtr exampleNode(new ExampleNode2D(domain, name));
exampleNode->initialize();
return exampleNode;
}

In this example, the node subscribes to listen a message defined earlier upon initialize:

void ExampleNode2D::initialize()
{
addMessageHandler(ExampleMessage, bind(&ExampleNode2D::onExampleMessage, this, placeholders::_1));
}
void ExampleNode2D::onExampleMessage(ExampleMessageArguments& arguments)
{
bool exampleArgument = arguments.getArgument(ExampleMessageArguments::ExampleArgumentProperty);
// Use argument value to set example property in node.
setExampleProperty(exampleArgument ? 1.0f : 0.0f);
}

For details of initialization, see the documentation of the Node class.

Attach and detach

When a node becomes a part of the node tree, it is attached. When a node is no longer a part of the node tree, it is detached. Nodes can also be attached or detached if their parent is attached or detached. This typically happens when the parent is added or removed from the node tree.

Attaching connects and activates node features related to its location in the node tree. This includes resource references, bindings, triggers, input manipulators, and so on.

For details on attach and detach, see the documentation of the Node class.

Rendering

Custom node rendering is controlled by overriding rendering functions and setting the render type. During the render process, nodes first call their rendering functions, then rendering descends to the children.

Rendering functions

To override the rendering of the foreground, implement renderForegroundOverride(). The default implementation of renderForegroundOverride() is empty, because all nodes decide on their own rendering.

To override the rendering of both the foreground and background, implement renderSelfOverride(). The default implementation of renderSelfOverride() applies the composition stack, and then defers to background and foreground rendering. When implementing this function, remember to ensure that the viewport settings are correct before you issue draw calls.

To use normal background rendering within overridden rendering, call renderBackground(). renderBackground() checks whether a background brush exists, and then renders the background quad. In the case of opaque foreground, background rendering renders a 'frame' around the node content area, if possible.

When you want to override the entire rendering process of a 2D node, implement renderOverride(). This can be necessary in some rare cases. For example, implement renderOverride() when you want to alter the way caching or the allocation of composition targets works.

For most nodes, implementing renderSelfOverride() is enough.

Render type

Node2D rendering is controlled by RenderType. Set it upon constructor or node initialization to reflect on node rendering behavior. RenderType acts as a hint to the rendering system, regarding how to set viewport settings and how to handle background rendering.

Layout

A custom node follows the layout directives described in the Basic layout section. You can override the layout partially by implementing layout functions.

Measurement pass

In measure(), Kanzi determines the desired size of a node.

The measurement pass descends recursively downwards until it finds nodes that are flagged as needing measure. For every node whose size changed, measure ascends upwards to the root and flags the node as requiring arrange.

To override the size that Kanzi otherwise determines for the node, implement measureOverride():

Vector2 ExampleNode2D::measureOverride(Vector2 /*availableSize*/)
{
return Vector2(128.0f, 128.0f);
}

The size returned by measureOverride() determines the desired size of the content. The desired size of the node is affected by the desired size of the content and the properties of the node.

Arrange pass

In arrange(), Kanzi determines the actual size and transformation of the node.

The arrange pass descends recursively downwards to nodes that are flagged as needing arrange, and then arranges those nodes and their children.

The arrange process:

  1. Reads the available size for the node.
  2. Determines the transformation and actual size of the node based on the properties of the node.

Nodes that perform layout on their child nodes must implement arrangeOverride(). During the arrange pass of the parent node, Kanzi already finished measuring the children nodes. Arranging children works by iterating over child nodes and setting their allocated sizes and arrange transformations. For non-layout nodes, (default) arrangeOverride() sets the allocated size of the child nodes as the actual size of the node, and resets child arrange transformation.

Update render pass

In updateRender(), Kanzi determines the final transformation, brushes, and composition settings of a node.

Kanzi calls updateRender() after arrange for all nodes that are marked as requiring a transformation update.

A node can implement updateRenderOverride() to do custom clipping or modify brush or composition settings:

void ExampleNode2D::updateRenderOverride()
{
// Check if we have a color brush as background brush.
if (brush)
{
// Set blue component of color depending on our example property.
ColorRGBA color = brush->getColor();
color.setBlue(getExampleProperty());
brush->setColor(color);
}
}

Member Typedef Documentation

◆ LayoutVectorType

◆ LayoutMatrixType

◆ ChildContainer

Container type for children.

◆ ChildConstIterator

typedef ChildContainer::const_iterator kanzi::Node2D::ChildConstIterator

Iterator type for children.

◆ ChildConstReverseIterator

typedef ChildContainer::const_reverse_iterator kanzi::Node2D::ChildConstReverseIterator

Reverse iterator type for children.

◆ HitTestVisitor

typedef NodeSharedPtr(* kanzi::Node2D::HitTestVisitor) (Node2D &node, Vector2 nodePoint, void *userData)

Hit test visitor function.

Member Enumeration Documentation

◆ PixelFormat

Pixel formats.

Enumerator
PixelFormatRgb 

Managed render targets use RGB format.

PixelFormatRgba 

Managed render targets use RGBA format.

◆ ForegroundHint

Hint for foreground handling of nodes.

Enumerator
ForegroundHintNone 

No hint given, assumed the background of a node can be rendered after content.

ForegroundHintTranslucent 

Some elements rendered within the node are translucent over the background.

ForegroundHintOpaque 

Node content is assumed to be fully opaque, meaning that there is no need to render the background.

◆ RenderType

Node2D render type - affects elementary decisions about node rendering.

Enumerator
RenderTypeNone 

Node has no foreground content to render.

RenderTypeTexture 

Node renders itself as a textured quad.

RenderTypeManual 

Node handles its own rendering.

RenderTypeManualClipped 

Node handles its own rendering, but also clips its own content.

This means that the node does not need additional composition area definitions, and can be rendered directly.

◆ PerspectiveTransformationMode

Node2D perspective transformation mode.

Enumerator
Screen 

Screen coordinates.

XFov 

3D coordinates with a field of view in x direction.

YFov 

3D coordinates with a field of view in y direction.

◆ Node2DFlags

Different Node2D flags for bit set.

Enumerator
AllowClear 

Is clearing allowed? This flag is turned on by default, but can be disabled by node properties.

2D nodes only clear color buffers, even if other buffers are created.

AllowRenderChildren 

Are children rendered for this node or are they handled in a special manner?

AllowRenderSelf 

Is the node allowed to render itself?

ForegroundIsTranslucent 

Does layout detected foreground translucency?

ForegroundTranslucencyRequested 

Has an extra request been filed (by implementations) for foreground translucency?.

RequiresBackgroundQuad 

Is background quad required.

RequiresLocalTransformationScope 

Node requires local transformation scope.

Set by specialized node classes that perform their own custom composition.

RequiresTilingUpdate 

Node requires tiling update.

Kanzi sets this when the value of a tiling property changes, and clears it after updating the node geometry.

Since
Kanzi 3.9.5
Node2DFlagsBitCount 

Number of options.

Constructor & Destructor Documentation

◆ ~Node2D()

kanzi::Node2D::~Node2D ( )
override

◆ Node2D()

kanzi::Node2D::Node2D ( Domain * domain,
string_view name )
explicitprotected

Constructor.

Parameters
domainDomain to use.
nameNode name.

Member Function Documentation

◆ layoutUp()

static float kanzi::Node2D::layoutUp ( )
inlinestatic

Returns the direction to which the y axis grows for this node type.

Returns
The direction of the y axis.

◆ isValidLayoutSize()

static bool kanzi::Node2D::isValidLayoutSize ( Vector2 size)
inlinestatic

Returns whether a size is a valid layout size.

A size is valid if all its elements are valid layout values.

Parameters
sizeThe size for which to test whether it is a valid layout size.
Returns
If the size is a valid layout size, true, otherwise false.
See also
Node::isValidLayoutValue()

◆ unboundedLayoutSize()

static Vector2 kanzi::Node2D::unboundedLayoutSize ( )
inlinestatic

Returns an unbound layout size.

Returns
Unbound layout size.

◆ isUnboundedLayoutSize()

static bool kanzi::Node2D::isUnboundedLayoutSize ( Vector2 layoutSize)
inlinestatic

Returns whether a layout size is an unbound layout size.

A size is a an unbound layout size if any of its elements is an unbounded layout value.

Parameters
layoutSizeThe layout size for which to test whether it is unbound layout size.
Returns
If the layout size is an unbound layout size,true, otherwise false.

◆ replaceUnboundedLayoutSize()

static Vector2 kanzi::Node2D::replaceUnboundedLayoutSize ( Vector2 layoutSize,
Vector2 resetSize )
inlinestatic

Replaces any element of a layout size with appropriate element of the reset size if it is unbounded and returns the size.

Parameters
layoutSizeLayout size to test if any of its elements is unbounded layout value.
resetSizeThe size whose values are used as a replacement for specified layout size's unbounded value elements.
Returns
layoutSize with its unbounded value elements replaced with the elements of resetSize.

◆ replaceUnboundedLayoutSizeWithZero()

static Vector2 kanzi::Node2D::replaceUnboundedLayoutSizeWithZero ( Vector2 layoutSize)
inlinestatic

Replaces any element of a layout size with zero if it is unbounded and returns the size.

Parameters
layoutSizeLayout size to test if any of its elements is unbounded layout value.
Returns
layoutSize with its unbounded value elements replaced with zero.

◆ getAspectRatio()

float kanzi::Node2D::getAspectRatio ( ) const
inline

Gets the value of AspectRatioProperty.

See also
setAspectRatio()

◆ setAspectRatio()

void kanzi::Node2D::setAspectRatio ( float value)
inline

Sets the value of AspectRatioProperty.

See also
getAspectRatio()

◆ isForceComposition()

bool kanzi::Node2D::isForceComposition ( ) const
inline

Gets the value of ForceCompositionProperty.

See also
setForceComposition()

◆ setForceComposition()

void kanzi::Node2D::setForceComposition ( bool value)
inline

Sets the value of ForceCompositionProperty.

See also
isForceComposition()

◆ getForegroundHint()

Node2D::ForegroundHint kanzi::Node2D::getForegroundHint ( ) const
inline

Gets the value of ForegroundHintProperty.

See also
setForegroundHint()

◆ setForegroundHint()

void kanzi::Node2D::setForegroundHint ( Node2D::ForegroundHint value)
inline

Sets the value of ForegroundHintProperty.

See also
getForegroundHint()

◆ isOffscreenRendering()

bool kanzi::Node2D::isOffscreenRendering ( ) const
inline

◆ setOffscreenRendering()

void kanzi::Node2D::setOffscreenRendering ( bool value)
inline

◆ isDisableRenderTargetClear()

bool kanzi::Node2D::isDisableRenderTargetClear ( ) const
inline

◆ setDisableRenderTargetClear()

void kanzi::Node2D::setDisableRenderTargetClear ( bool value)
inline

◆ getPixelFormat()

Node2D::PixelFormat kanzi::Node2D::getPixelFormat ( ) const
inline

Gets the value of PixelFormatProperty.

See also
setPixelFormat()

◆ setPixelFormat()

void kanzi::Node2D::setPixelFormat ( Node2D::PixelFormat value)
inline

Sets the value of PixelFormatProperty.

See also
getPixelFormat()

◆ isRenderSelf()

bool kanzi::Node2D::isRenderSelf ( ) const
inline

Gets the value of RenderSelfProperty.

See also
setRenderSelf()

◆ setRenderSelf()

void kanzi::Node2D::setRenderSelf ( bool value)
inline

Sets the value of RenderSelfProperty.

See also
isRenderSelf()

◆ getRenderTargetMinimumHeight()

float kanzi::Node2D::getRenderTargetMinimumHeight ( ) const
inline

◆ setRenderTargetMinimumHeight()

void kanzi::Node2D::setRenderTargetMinimumHeight ( float value)
inline

◆ getRenderTargetMinimumWidth()

float kanzi::Node2D::getRenderTargetMinimumWidth ( ) const
inline

◆ setRenderTargetMinimumWidth()

void kanzi::Node2D::setRenderTargetMinimumWidth ( float value)
inline

◆ getRenderTargetReallocationLimit()

float kanzi::Node2D::getRenderTargetReallocationLimit ( ) const
inline

◆ setRenderTargetReallocationLimit()

void kanzi::Node2D::setRenderTargetReallocationLimit ( float value)
inline

◆ getCachingMode()

CachingMode kanzi::Node2D::getCachingMode ( ) const
inline

Gets the value of CachingModeProperty.

See also
setCachingMode()
Returns
Caching mode value.
Since
Kanzi 3.9.0

◆ setCachingMode()

void kanzi::Node2D::setCachingMode ( CachingMode value)
inline

Sets the value of CachingModeProperty.

See also
getCachingMode()
Parameters
valueNew caching mode value.
Since
Kanzi 3.9.0

◆ getPerspectiveTransformation()

SRTValue3D kanzi::Node2D::getPerspectiveTransformation ( ) const
inline

◆ setPerspectiveTransformation()

void kanzi::Node2D::setPerspectiveTransformation ( SRTValue3D value)
inline

◆ getPerspectiveTransformationMode()

PerspectiveTransformationMode kanzi::Node2D::getPerspectiveTransformationMode ( ) const
inline

◆ setPerspectiveTransformationMode()

void kanzi::Node2D::setPerspectiveTransformationMode ( PerspectiveTransformationMode value)
inline

◆ getPerspectiveTransformationFov()

float kanzi::Node2D::getPerspectiveTransformationFov ( ) const
inline

◆ setPerspectiveTransformationFov()

void kanzi::Node2D::setPerspectiveTransformationFov ( float value)
inline

◆ getPerspectiveTransformationPivot()

Vector3 kanzi::Node2D::getPerspectiveTransformationPivot ( ) const
inline

◆ setPerspectiveTransformationPivot()

void kanzi::Node2D::setPerspectiveTransformationPivot ( Vector3 value)
inline

◆ getPerspectiveTransformationOrigin()

Vector3 kanzi::Node2D::getPerspectiveTransformationOrigin ( ) const
inline

◆ setPerspectiveTransformationOrigin()

void kanzi::Node2D::setPerspectiveTransformationOrigin ( Vector3 value)
inline

◆ getRenderTransformationOrigin()

Vector2 kanzi::Node2D::getRenderTransformationOrigin ( ) const
inline

◆ setRenderTransformationOrigin()

void kanzi::Node2D::setRenderTransformationOrigin ( Vector2 value)
inline

◆ isSnapToPixel()

bool kanzi::Node2D::isSnapToPixel ( ) const
inline

Gets the value of SnapToPixelProperty.

See also
setSnapToPixel()

◆ setSnapToPixel()

void kanzi::Node2D::setSnapToPixel ( bool value)
inline

Sets the value of SnapToPixelProperty.

See also
isSnapToPixel()

◆ getMultisampleLevel()

MultisampleCount kanzi::Node2D::getMultisampleLevel ( ) const
inline

Gets the value of MultisampleLevelProperty.

See also
setMultisampleLevel()
Since
Kanzi 3.9.7

◆ setMultisampleLevel()

void kanzi::Node2D::setMultisampleLevel ( MultisampleCount value)
inline

Sets the value of MultisampleLevelProperty.

See also
getMultisampleLevel()
Since
Kanzi 3.9.7

◆ makeEditorInfo()

static PropertyTypeEditorInfoSharedPtr kanzi::Node2D::makeEditorInfo ( )
static

◆ beginChildren()

ChildConstIterator kanzi::Node2D::beginChildren ( ) const

◆ endChildren()

ChildConstIterator kanzi::Node2D::endChildren ( ) const

◆ rbeginChildren()

ChildConstReverseIterator kanzi::Node2D::rbeginChildren ( ) const

◆ rendChildren()

ChildConstReverseIterator kanzi::Node2D::rendChildren ( ) const

◆ addChild()

void kanzi::Node2D::addChild ( Node2DSharedPtr child)

Adds a child node.

Adding a 3D node node as a child of a 2D node is only allowed when adding a scene to a viewport. Screens can have only one child which is a 2D node.

◆ insertChild()

void kanzi::Node2D::insertChild ( size_t index,
Node2DSharedPtr child )

Adds a child node for object node to given index.

Adding a 3D node node as a child of a 2D node is only allowed when adding a scene to a viewport. Screens can have only one child which is a 2D node.

◆ removeChild() [1/2]

void kanzi::Node2D::removeChild ( const Node & child)

Removes child node.

◆ removeChild() [2/2]

void kanzi::Node2D::removeChild ( size_t index)

Removes child node at specified index.

◆ removeAllChildren()

void kanzi::Node2D::removeAllChildren ( )

Removes all child nodes.

◆ getChild()

Node2DSharedPtr kanzi::Node2D::getChild ( size_t index) const

Returns a child from given index from object node.

◆ getChildIndex()

size_t kanzi::Node2D::getChildIndex ( const Node & child) const

Returns the index of a child in an object node.

◆ hasChild()

bool kanzi::Node2D::hasChild ( const Node & child) const

Returns whether the given node is a child of this node.

Parameters
childThe node to check.

◆ getChildCount()

size_t kanzi::Node2D::getChildCount ( ) const

Gets the number of children of the node.

◆ moveToBack()

void kanzi::Node2D::moveToBack ( )

Repositions the node to the beginning of its parent's children, so that it is drawn first.

◆ moveToFront()

void kanzi::Node2D::moveToFront ( )

Repositions the node to the end of its parent's children, so that it is drawn last.

◆ moveChildToPosition()

void kanzi::Node2D::moveChildToPosition ( Node2DSharedPtr child,
size_t index )

Moves a child node to a given position in the list of child nodes.

Parameters
childChild node to reposition.
indexPosition at which to place the child node in the list of child nodes.
Since
Kanzi 3.9.3

◆ getRenderType()

RenderType kanzi::Node2D::getRenderType ( ) const
inline

Get render type.

Returns
Render type enumeration.

◆ getEffect()

NodeEffect2DSharedPtr kanzi::Node2D::getEffect ( ) const
inline

Gets the value of EffectProperty.

Since
Kanzi 3.9.0

◆ getRenderableEffect()

NodeEffect2D * kanzi::Node2D::getRenderableEffect ( ) const
inline

Gets a pointer to the current effect if effect rendering is required.

Returns
If an effect is set and the effect is renderable, returns a pointer to the effect, otherwise nullptr.

◆ getEffectRenderer()

NodeEffectRenderer2D * kanzi::Node2D::getEffectRenderer ( ) const
inline

Gets the effect renderer.

The effect renderer is set only if the effect is both set and is renderable.

Returns
Pointer to effect renderer.

◆ hasEffect()

bool kanzi::Node2D::hasEffect ( ) const
inline

Whether an active effect is applied to this node.

Returns
If an active effect is applied, true, otherwise false.
Since
Kanzi 3.9.0

◆ getEffectPrefab()

NodeEffectPrefab2DSharedPtr kanzi::Node2D::getEffectPrefab ( ) const
inline

Gets the value of EffectPrefabProperty.

Since
Kanzi 3.9.0

◆ setEffectPrefab()

void kanzi::Node2D::setEffectPrefab ( NodeEffectPrefab2DSharedPtr value)
inline

Sets the value of EffectPrefabProperty.

Since
Kanzi 3.9.0

◆ getBackgroundBrush()

BrushSharedPtr kanzi::Node2D::getBackgroundBrush ( ) const
inline

Gets value of BackgroundBrushProperty.

◆ setBackgroundBrush()

void kanzi::Node2D::setBackgroundBrush ( BrushSharedPtr value)
inline

Sets value of BackgroundBrushProperty.

◆ getCompositionBrush()

BrushSharedPtr kanzi::Node2D::getCompositionBrush ( ) const
inline

Gets value of CompositionBrushProperty.

◆ setCompositionBrush()

void kanzi::Node2D::setCompositionBrush ( BrushSharedPtr value)
inline

Sets value of CompositionBrushProperty.

◆ getForegroundBrush()

BrushSharedPtr kanzi::Node2D::getForegroundBrush ( ) const
inline

Gets value of ForegroundBrushProperty.

◆ setForegroundBrush()

void kanzi::Node2D::setForegroundBrush ( BrushSharedPtr value)
inline

Sets value of ForegroundBrushProperty.

◆ getBackgroundBrushRenderer()

BrushRenderer * kanzi::Node2D::getBackgroundBrushRenderer ( ) const
inline

Get background brush renderer.

Returns
Pointer to background brush renderer.

◆ getForegroundBrushRenderer()

BrushRenderer * kanzi::Node2D::getForegroundBrushRenderer ( ) const
inline

Get foreground brush renderer.

Returns
Pointer to foreground brush renderer.

◆ getCompositionBrushRenderer()

BrushRenderer * kanzi::Node2D::getCompositionBrushRenderer ( ) const
inline

Access cache result brush renderer.

Returns
Pointer to brush renderer.

◆ getRenderTransformation()

SRTValue2D kanzi::Node2D::getRenderTransformation ( ) const
inline

◆ setRenderTransformation()

void kanzi::Node2D::setRenderTransformation ( SRTValue2D value)
inline

◆ render() [1/2]

void kanzi::Node2D::render ( Renderer3D & renderer,
CompositionStack & compositionStack,
const optional< Matrix3x3 > & baseTransform )

Renders a node and its descendant nodes.

Parameters
rendererRenderer to use.
compositionStackRender context stack to use.
baseTransformOptional transform in composition space.

◆ render() [2/2]

void kanzi::Node2D::render ( Renderer3D & renderer,
CompositionStack & compositionStack )
inline

Render a node and its descendant nodes.

Omits the base transformation.

Parameters
rendererRenderer to use.
compositionStackRender context stack to use.

◆ getVisual()

NodeVisual2D * kanzi::Node2D::getVisual ( ) const
inline

Access visual component.

Returns
Pointer to visual component or NULL if it doesn't exist.

◆ getRenderTarget()

TextureSharedPtr kanzi::Node2D::getRenderTarget ( ) const
inline

Gets value of RenderTargetProperty.

◆ setRenderTarget()

void kanzi::Node2D::setRenderTarget ( TextureSharedPtr texture)
inline

Sets value of RenderTargetProperty.

◆ getCompositionTarget()

TextureSharedPtr kanzi::Node2D::getCompositionTarget ( ) const
inline

Gets the composition target used for compositing the node.

The composition target can be set manually by you or created automatically by Kanzi.

Returns
Composition target for the node or nullptr.

◆ hasCompositionTarget()

bool kanzi::Node2D::hasCompositionTarget ( ) const
inline

Indicates whether the node has a composition target.

Returns
If the node has a composition target, true, otherwise false.

◆ getManagedCompositionTarget()

TextureSharedPtr kanzi::Node2D::getManagedCompositionTarget ( ) const
inline

Gets the managed composition target of a node.

Returns
The managed composition target or nullptr.

◆ hasManagedCompositionTarget()

bool kanzi::Node2D::hasManagedCompositionTarget ( ) const
inline

Returns whether the node has a managed composition target.

Returns
If the node has a managed composition target, true, otherwise false.

◆ isCacheValid()

bool kanzi::Node2D::isCacheValid ( ) const
inline

Returns whether the children cache is valid.

Returns
If the cache is valid, true, otherwise false.

◆ resetCache()

void kanzi::Node2D::resetCache ( )
inline

Resets cached content for complete content of a node, including the node and its children.

Does not change the caching property. If caching is enabled, Kanzi recreates the cache on next render.

◆ getCompositionManager()

CompositionManager * kanzi::Node2D::getCompositionManager ( ) const
inline

Access composition manager.

◆ getCompositor()

NodeCompositor2D * kanzi::Node2D::getCompositor ( ) const
inline

Accesses the compositor component.

Returns
Pointer to compositor component or, if the component does not exist, nullptr.

◆ setAutoWidth()

void kanzi::Node2D::setAutoWidth ( )

Sets a node to determine its width automatically.

◆ setAutoHeight()

void kanzi::Node2D::setAutoHeight ( )

Sets a node to determine its height automatically.

◆ setAutoSize()

void kanzi::Node2D::setAutoSize ( )

Sets a node to determine its width and height automatically.

◆ setSize() [1/2]

void kanzi::Node2D::setSize ( float width,
float height )

Sets the size of a node.

Parameters
widthThe width to set.
heightThe height to set.

◆ setSize() [2/2]

void kanzi::Node2D::setSize ( Vector2 size)
inline

Sets the size of a node.

Parameters
sizeA vector that contains the width and height to set.

◆ setLayoutSize()

KZ_DEPRECATED void kanzi::Node2D::setLayoutSize ( float width,
float height )
inline

Sets size properties of the node.

Deprecated
Use setSize() instead.
See also
setSize

◆ getLayoutTransformation()

SRTValue2D kanzi::Node2D::getLayoutTransformation ( ) const
inline

◆ setLayoutTransformation()

void kanzi::Node2D::setLayoutTransformation ( SRTValue2D value)
inline

◆ getDesiredSize()

Vector2 kanzi::Node2D::getDesiredSize ( ) const
inline

Gets the desired size of a node.

Returns
Size vector.

◆ setDesiredSize()

void kanzi::Node2D::setDesiredSize ( Vector2 desiredSize)
inline

Sets the desired size of a node.

Parameters
desiredSizeA vector that contains the size to set.

◆ getAllocatedSize()

Vector2 kanzi::Node2D::getAllocatedSize ( ) const
inline

Gets the allocated size of a node.

Returns
Size vector.

◆ setAllocatedSize()

void kanzi::Node2D::setAllocatedSize ( Vector2 allocatedSize)
inline

Sets the allocated size of a node.

If the allocated size differs from the existing allocated size, calling this function invalidates the arrange.

Parameters
allocatedSizeA vector that contains the size to set.

◆ getActualSize()

Vector2 kanzi::Node2D::getActualSize ( ) const
inline

Gets the actual size of a node.

Returns
Size vector.

◆ setActualSize() [1/2]

void kanzi::Node2D::setActualSize ( Vector2 actualSize)
inline

Sets the actual size of a node.

Parameters
actualSizeA vector that contains the size to set.

◆ setActualSize() [2/2]

void kanzi::Node2D::setActualSize ( float sizeX,
float sizeY )
inline

Sets the actual size of a node.

Parameters
sizeXThe x component of the size.
sizeYThe y component of the size.

◆ getArrangeTransform()

Matrix3x3 kanzi::Node2D::getArrangeTransform ( ) const
inline

Gets the arrange transform.

Returns
Transformation matrix.

◆ setArrangeTransform()

void kanzi::Node2D::setArrangeTransform ( Matrix3x3 transform)
inline

Sets the arrange transform.

If the layout transform differs from the existing transform, calling this function invalidates the arrange.

Parameters
transformTransformation matrix.

◆ layout() [1/2]

void kanzi::Node2D::layout ( optional< Matrix3x3 > rootTransform)

Does a layout pass starting from this node and iterating recursively all of its children.

Measure pass only descends up to nodes marked for requiring measure and then propagates upwards for all nodes that were changed. After measure, all nodes marked for requiring arrange and all their children are arranged.

The actual size of a node is not known before layout. You can call layout manually to determine the actual sizes of nodes. Before calling layout, the node must have allocated size set to limit node area to anything less than infinity. Normal layout process sets allocated size to current composition size.

Parameters
rootTransformTransform applied to root node for arrange pass if set. Can be used to offset complete node tree, but should usually be empty.

◆ layout() [2/2]

void kanzi::Node2D::layout ( )
inline

Does layout pass with no root transformation (identity).

Otherwise same as layout() with optional Matrix3x3.

◆ measure()

bool kanzi::Node2D::measure ( const Vector2 * availableSize,
bool handleStretch )

Measures one node.

Parameters
availableSizeAvailable size passed from parent, can be NULL.
handleStretchWhether the node should handle stretching of node to fill available space.
Returns
If measure needs to be propagated, true, otherwise false.

◆ measureRecursive()

virtual bool kanzi::Node2D::measureRecursive ( )
virtual

Performs measure recursively.

Reimplemented in kanzi::Viewport2D.

◆ arrange()

void kanzi::Node2D::arrange ( )

Performs layout arrangement on a 2D node.

◆ transform()

void kanzi::Node2D::transform ( )
inline

Transforms a 2D node.

Since
3.9.4

◆ getWorldTransform()

Matrix3x3 kanzi::Node2D::getWorldTransform ( ) const
inline

Gets the world transformation matrix.

Returns
Transformation matrix.

◆ containsLocal()

bool kanzi::Node2D::containsLocal ( Vector2 point) const

Returns whether a node area contains a point defined in the local space of the node.

Returns
If the node area contains the point, true, otherwise false.

◆ containsGlobal()

optional< Vector2 > kanzi::Node2D::containsGlobal ( Vector2 point) const

Checks whether a node area contains a point defined in screen space. If it does, writes the node-space coordinates into the outgoing point.

◆ globalToLocal()

optional< Vector2 > kanzi::Node2D::globalToLocal ( Vector2 point) const

◆ hitTest() [1/4]

NodeSharedPtr kanzi::Node2D::hitTest ( Vector2 point)

Performs a hit test to a 2D node and all its child nodes.

Returns the topmost 2D node under given point.

Parameters
pointPoint in world coordinates.
Returns
Node hit or an empty shared pointer.

◆ hitTest() [2/4]

NodeSharedPtr kanzi::Node2D::hitTest ( Vector2 point,
const Metaclass * type )

Performs a hit test to a 2D node and all its child nodes.

This is a wrapper function that allows to filter only selected types of nodes for hit testing.

Parameters
pointPoint in world coordinates.
typeMetaclass type to limit hit testing to.
Returns
Node hit or an empty shared pointer.

◆ hitTestIterate()

NodeSharedPtr kanzi::Node2D::hitTestIterate ( Vector2 point,
HitTestVisitor visitor,
void * userData )

Hit tests nodes recursively from this node downwards and calls visitor function on the hit nodes.

Used for specific implementations of hit testing.

Parameters
pointPoint in world coordinates.
visitorVisitor function to call on nodes.
userDataUser data passed to visitor function.
Returns
Node hit or an empty shared pointer.

◆ hitTestContent()

virtual tuple< NodeSharedPtr, Ray, float > kanzi::Node2D::hitTestContent ( Vector2 point)
virtual

Default implementation of Node2D content hit test.

Returns the node itself.

Parameters
pointPoint in node space.
Returns
Tuple of found node, ray hitting that node and distance along the ray.

Reimplemented in kanzi::Viewport2D.

◆ hitTest() [3/4]

template<typename T >
shared_ptr< T > kanzi::Node2D::hitTest ( Vector2 point)
inline

Wrapper for hitTest(Vector2), casts the return value.

Parameters
pointPoint in world coordinates.
Returns
Typed node hit or an empty shared pointer.

◆ hitTest() [4/4]

template<typename T >
shared_ptr< T > kanzi::Node2D::hitTest ( Vector2 point,
const Metaclass * type )
inline

Wrapper for hitTest(Vector2, const Metaclass), casts the return value.

Parameters
pointPoint in world coordinates.
typeMetaclass type to limit hit testing to.
Returns
Typed node hit or an empty shared pointer.

◆ findAbstractChildOverride()

NodeSharedPtr kanzi::Node2D::findAbstractChildOverride ( string_view name)
overridevirtual

Node::findAbstractChildOverride() implementation.

Implements kanzi::Node.

Reimplemented in kanzi::Viewport2D.

◆ visitAbstractChildOverride()

VisitorResult kanzi::Node2D::visitAbstractChildOverride ( const Visitor & visitor,
VisitorOrder order )
overridevirtual

Node::visitAbstractChild implementation.

Implements kanzi::Node.

Reimplemented in kanzi::Viewport2D.

◆ addAbstractChildOverride()

bool kanzi::Node2D::addAbstractChildOverride ( NodeSharedPtr child)
overridevirtual

Node::addAbstractChildOverride() implementation.

Implements kanzi::Node.

◆ getAbstractChildCountOverride()

size_t kanzi::Node2D::getAbstractChildCountOverride ( )
overridevirtual

Node::getAbstractChildCountOverride() implementation.

Implements kanzi::Node.

Reimplemented in kanzi::Viewport2D.

◆ getAbstractChildIndexOverride()

size_t kanzi::Node2D::getAbstractChildIndexOverride ( const Node & node)
overridevirtual

Implements kanzi::Node.

Reimplemented in kanzi::Viewport2D.

◆ getAbstractChildOverride()

NodeSharedPtr kanzi::Node2D::getAbstractChildOverride ( size_t index)
overridevirtual

Node::getAbstractChildOverride() implementation.

Implements kanzi::Node.

Reimplemented in kanzi::Viewport2D.

◆ removeAbstractChildOverride()

bool kanzi::Node2D::removeAbstractChildOverride ( Node & child)
overridevirtual

Node::removeAbstractChildOverride() implementation.

Implements kanzi::Node.

◆ moveAbstractChildToPositionOverride()

bool kanzi::Node2D::moveAbstractChildToPositionOverride ( NodeSharedPtr child,
size_t index )
overridevirtual

Node::moveAbstractChildToPosition() implementation.

Implements kanzi::Node.

◆ compositionRequiresAlpha()

bool kanzi::Node2D::compositionRequiresAlpha ( ) const
inline

Returns whether composition requires alpha.

Returns
If composition requires alpha, true, otherwise false.

◆ setCompositionRequiresAlpha()

void kanzi::Node2D::setCompositionRequiresAlpha ( bool enabled)
inline

Turns the composition alpha requirement on or off.

Parameters
enabledTo enable the composition alpha requirement, pass true. To disable the composition alpha requirement, pass false.

◆ compositionRequiresDepth()

bool kanzi::Node2D::compositionRequiresDepth ( ) const
inline

Returns whether composition requires depth.

Returns
If composition requires depth, true, otherwise false.

◆ setCompositionRequiresDepth()

void kanzi::Node2D::setCompositionRequiresDepth ( bool enabled)
inline

Turns the composition depth requirement on or off.

Parameters
enabledTo enable the composition depth requirement, pass true. To disable the composition depth requirement, pass false.

◆ compositionRequiresStencil()

bool kanzi::Node2D::compositionRequiresStencil ( ) const
inline

Returns whether composition requires stencil.

Returns
If composition requires stencil, true, otherwise false.

◆ setCompositionRequiresStencil()

void kanzi::Node2D::setCompositionRequiresStencil ( bool enabled)
inline

Turns the composition stencil requirement on or off.

Parameters
enabledTo enable the composition stencil requirement, pass true. To disable the composition stencil requirement, pass false.

◆ getBackgroundQuad()

QuadDescription kanzi::Node2D::getBackgroundQuad ( ) const
inline

Gets the background quad description.

This function returns a copy of the background quad struct. Use this function only for tests.

◆ getClippingArea()

ClippingArea kanzi::Node2D::getClippingArea ( ) const
inline

Gets the clipping area.

This function returns a copy of the clipping struct. Use this function only for tests.

◆ getLayoutOpacity()

float kanzi::Node2D::getLayoutOpacity ( ) const
inline

Gets the opacity after propagation from layouting hierarchy.

Returns
Current layouted opacity.

◆ getParentSpaceTransform()

Matrix3x3 kanzi::Node2D::getParentSpaceTransform ( ) const
inline

Gets the parent space transform of the 2D node.

Returns
Parent space transform.

◆ getChildCompositionSpaceTransform()

Matrix3x3 kanzi::Node2D::getChildCompositionSpaceTransform ( ) const
inline

Gets the transform used for composition children of the 2D node.

Kanzi uses the same transform for rendering the background and foreground of the node.

Returns
Child composition space transform.

◆ getRenderQuadTransform()

Matrix3x3 kanzi::Node2D::getRenderQuadTransform ( ) const
inline

Gets transformation used to render the 2D node.

Returns
Transform used for rendering the quad.

◆ hasCenterClipArea()

bool kanzi::Node2D::hasCenterClipArea ( ) const
inline

Returns whether a 2D node has the center clip area (the area of foreground content).

Returns
If the node has the area, true, otherwise false.

◆ hasOutsideClipArea()

bool kanzi::Node2D::hasOutsideClipArea ( ) const
inline

Returns whether a 2D node has outside clipping area.

This means any area outside the foreground content.

Returns
If the node has the area, true, otherwise false.

◆ hasTranslucentForeground()

bool kanzi::Node2D::hasTranslucentForeground ( ) const
inline

Returns whether the foreground of a 2D node has translucency.

For the contributing flags, see setForegroundIsTranslucent() and setForegroundTranslucencyRequested().

Returns
If the foreground has translucency, true, otherwise false.

◆ setForegroundIsTranslucent()

void kanzi::Node2D::setForegroundIsTranslucent ( bool enabled)
inline

Sets the status of the foreground translucency.

To combine the factors that determine translucency, Kanzi calculates this flag from layout time.

Parameters
enabledTo enable foreground translucency, pass true. To disable foreground translucency, pass false.

◆ setForegroundTranslucencyRequested()

void kanzi::Node2D::setForegroundTranslucencyRequested ( bool enabled)
inline

Enables or disables the foreground translucency request.

Use this to request "extra" translucency in the updateRenderOverride() implementations of inherited classes. The extra request for translucency does not affect the default rendering of the foreground or background brush, but it can affect the format of the allocated composition target.

Parameters
enabledTo enable the foreground translucency request, pass true. To disable the foreground translucency request, pass false.

◆ setCompositionRequested()

void kanzi::Node2D::setCompositionRequested ( bool enabled)
inline

Turns the composition request on or off.

This is a composition request from code, not by setting a property.

Parameters
enabledTo enable the composition request, pass true. To disable the composition request, pass false.

◆ setPotentialCompositionBitViewport()

void kanzi::Node2D::setPotentialCompositionBitViewport ( bool enabled)
inline

Turns the potential composition flag for the viewport on or off.

Parameters
enabledTo enable the composition flag, pass true. To disable the composition flag, pass false.

◆ isClearColorAllowed()

bool kanzi::Node2D::isClearColorAllowed ( ) const
inline

Returns whether this Node2D is allowed and should clear the color buffer of its own composition target.

By default, clearing is allowed but can be explicitly denied by user using properties.

This function does not access the property, but a flag determined during layout.

◆ setClearColorAllowed()

void kanzi::Node2D::setClearColorAllowed ( bool enabled)
inline

Sets clear color allowed.

Parameters
enabledTo set clear color allowed, pass true. To set clear color not allowed, pass false.

◆ isRenderChildrenAllowed()

bool kanzi::Node2D::isRenderChildrenAllowed ( ) const
inline

Returns whether rendering children is allowed.

Returns
If rendering children is allowed, true, otherwise false.

◆ isRenderSelfAllowed()

bool kanzi::Node2D::isRenderSelfAllowed ( ) const
inline

Returns whether render self is allowed.

Returns
If render self is allowed, true, otherwise false.

◆ isVisibleForHitTesting()

bool kanzi::Node2D::isVisibleForHitTesting ( ) const
inline

Returns whether a 2D node is visible for hit testing.

For a node to be visible for hit testing, that node must be visible and not be rendered off-screen.

Returns
If the node is visible for hit testing, true, otherwise false.

◆ requiresBackgroundBrushRendering()

bool kanzi::Node2D::requiresBackgroundBrushRendering ( ) const
inline

Returns whether background brush rendering is required.

Returns
If background brush rendering is required, true, otherwise false.

◆ requiresForegroundBrushRendering()

bool kanzi::Node2D::requiresForegroundBrushRendering ( ) const
inline

Returns whether foreground brush rendering is required.

Returns
If foreground brush rendering is required, true, otherwise false.

◆ requiresLocalTransformationScope()

bool kanzi::Node2D::requiresLocalTransformationScope ( ) const
inline

Indicates whether local transformation scope is required.

Returns
If local transformation scope is required, true, otherwise false.

◆ setRequiresLocalTransformationScope()

void kanzi::Node2D::setRequiresLocalTransformationScope ( bool enabled)
inline

Sets the local transformation scope requirement.

Parameters
enabledTo enable, set to true. To disable, set to false.

◆ requiresTilingUpdate()

bool kanzi::Node2D::requiresTilingUpdate ( ) const
inline

Returns whether node geometry requires an update for the tiling.

Returns
If an update is required for tiling, true, otherwise false.
Since
Kanzi 3.9.5

◆ setRequiresTilingUpdate()

void kanzi::Node2D::setRequiresTilingUpdate ( bool enabled)
inline

Sets the tiling update requirement.

Parameters
enabledTo enable the tiling update requirement, set to true. To disable the tiling update requirement, set to false.
Since
Kanzi 3.9.5

◆ isSelfInCompositionTarget()

bool kanzi::Node2D::isSelfInCompositionTarget ( ) const
inline

Returns whether the node is going to get rendered into a composition target.

Returns
If node is going the get rendered to a composition target, true, otherwise false.

◆ isCompositionPotentiallyRequired()

bool kanzi::Node2D::isCompositionPotentiallyRequired ( ) const
inline

Tell if node itself is going to get rendered into a composition target.

Returns
If node is going the get rendered to a composition target true, otherwise false.

◆ getContentDesiredSize()

Vector2 kanzi::Node2D::getContentDesiredSize ( ) const
inline

Gets the size desired by content.

Returns
Size vector.

◆ getSecondPassDesiredSize()

Vector2 kanzi::Node2D::getSecondPassDesiredSize ( ) const
inline

Gets the second pass desired size.

Returns
Size vector.

◆ getUserDesiredSize()

Vector2 kanzi::Node2D::getUserDesiredSize ( ) const
inline

Gets the size desired by user.

Returns
Size vector.

◆ getPartialArrangeTransform()

Matrix3x3 kanzi::Node2D::getPartialArrangeTransform ( ) const
inline

Gets the partial arrange transform.

Returns
Propagate transform.

◆ isCompletelyClipped()

bool kanzi::Node2D::isCompletelyClipped ( ) const
inline

Returns whether a node is completely clipped and needs not be rendered.

Returns
If the node is completely clipped, true, otherwise false.

◆ isCompletelyTransparent()

bool kanzi::Node2D::isCompletelyTransparent ( ) const
inline

Returns whether a node is completely transparent.

Returns
If the node is completely transparent, true, otherwise false.

◆ isPerspectiveTransformActive()

bool kanzi::Node2D::isPerspectiveTransformActive ( ) const
inline

Returns whether a node is being perspective transformed.

Returns
If the node is being perspective transformed, true, otherwise false. Kanzi sets the internal active status during layout.

◆ initialize()

void kanzi::Node2D::initialize ( )
protected

Node2D -specific initialization.

◆ acquireVisual()

NodeVisual2D & kanzi::Node2D::acquireVisual ( )
protected

Initializes and returns visual structure.

Allocates memory for rendering-related information. By default this information is unallocated.

◆ renderOverride()

virtual void kanzi::Node2D::renderOverride ( Renderer3D & renderer,
CompositionStack & compositionStack,
const optional< Matrix3x3 > & baseTransform )
protectedvirtual

Node-specific top-level render call.

Allows for overriding the complete Node2D rendering process. Should normally not be overridden. Even if overridden, inherited implementations should usually call base implementation.

Parameters
rendererRenderer.
compositionStackRender context stack.
baseTransformOptional additional transform in the composition space.

◆ renderRecursive()

void kanzi::Node2D::renderRecursive ( Renderer3D & renderer,
CompositionStack & compositionStack,
const optional< Matrix3x3 > & baseTransform )
protected

Renders a Node2D and then recursively all its children.

The base transform is optional. If it is set, Kanzi multiplies it with the transform of the node.

Parameters
rendererRenderer.
compositionStackRender context stack.
baseTransformOptional transform for rendered content.

◆ renderSelfOverride()

virtual void kanzi::Node2D::renderSelfOverride ( Renderer3D & renderer,
CompositionStack & compositionStack,
const optional< Matrix3x3 > & baseTransform )
protectedvirtual

Node-specific rendering.

Default implementation renders background normally and passes to foreground render. Inherit to render more complex forms. The base transform is optional. If it is set, Kanzi multiplies it with the transform of the node.

Parameters
rendererRenderer.
compositionStackRender context stack.
baseTransformTransform applied to node itself in parent space.

Reimplemented in kanzi::Portal, kanzi::ProgressiveRenderingViewport2D, and kanzi::Viewport2D.

◆ renderChildren()

void kanzi::Node2D::renderChildren ( Renderer3D & renderer,
CompositionStack & compositionStack,
const optional< Matrix3x3 > & baseTransform )
protected

Renders all children of a Node2D.

The base transform is optional. If it is set, Kanzi multiplies it with the transform of the node.

Parameters
rendererRenderer.
compositionStackRender context stack.
baseTransformTransform applied to node itself in parent space.

◆ renderBackground()

void kanzi::Node2D::renderBackground ( Renderer3D & renderer,
const CompositionStack & compositionStack,
const Matrix3x3 & transform )
protected

Renders the background quad of a Node2D.

Parameters
rendererRenderer.
compositionStackRender context stack.
transformTransform used to render the foreground.

◆ renderForeground()

void kanzi::Node2D::renderForeground ( Renderer3D & renderer,
CompositionStack & compositionStack,
const Matrix3x3 & transform )
protected

Renders the foreground of a Node2D.

Calls renderForegroundOverride().

Parameters
rendererRenderer.
compositionStackRender context stack.
transformTransform used to render the foreground.

◆ renderForegroundOverride()

virtual void kanzi::Node2D::renderForegroundOverride ( Renderer3D & renderer,
CompositionStack & compositionStack,
const Matrix3x3 & transform )
protectedvirtual

Node-specific foreground render.

Default implementation renders the center clip area from using the assigned foreground brush.

Parameters
rendererRenderer.
compositionStackRender context stack.
transformTransform used to render the foreground.

Reimplemented in kanzi::TextBox2D, and kanzi::TextBlock2D.

◆ pushLocalViewportArea()

bool kanzi::Node2D::pushLocalViewportArea ( CompositionStack & compositionStack,
const optional< Matrix3x3 > & baseTransform )
protected

Pushes local viewport and scissor area into composition stack if it is required.

Nodes with render type RenderTypeManual rely on viewport and scissoring settings to clip their output. This needs an additional composition area pushed to the composition stack.

Parameters
compositionStackComposition stack.
baseTransformOptional transform in composition space.
Returns
True if a new area was pushed into composition stack and needs to be popped after rendering.

◆ acquireCompositor()

NodeCompositor2D & kanzi::Node2D::acquireCompositor ( )
protected

Initializes and returns composition structure.

Allocates memory for all composition-related information. By default this information is unallocated.

Returns
Reference to the compositor.

◆ applyCompositionForRenderSelf()

Matrix3x3 kanzi::Node2D::applyCompositionForRenderSelf ( Renderer3D & renderer,
CompositionStack & compositionStack,
const optional< Matrix3x3 > & baseTransform )
protected

Applies composition for rendering the node.

Used in the standard render path. Either applies the perspective projection or uses the current composition stack as-is. Can be used in inheriting classes implementing renderSelfOverride() but not wanting to re-invent perspective transform.

Parameters
rendererRenderer.
compositionStackRender context stack.
baseTransformTransform applied to node itself in parent space.
Returns
Matrix to be passed to rendering the node.

◆ clearCompositionTarget()

void kanzi::Node2D::clearCompositionTarget ( Renderer3D & renderer,
CompositionStack & compositionStack )
protected

Clears the composition target of a 2D node.

Kanzi executes this function before rendering the node into its composition target.

Parameters
rendererRenderer to use.
compositionStackRender context stack.
Since
Kanzi 3.9.6 removed clearColor parameter.

◆ measureOverride()

◆ arrangeRecursive()

virtual void kanzi::Node2D::arrangeRecursive ( const Matrix3x3 & worldTransform,
const Matrix3x3 & parentTransform,
bool arrangeNeeded,
bool transformChanged )
protectedvirtual

Perform arrange recursively.

Reimplemented in kanzi::Viewport2D.

◆ arrangeOverride()

◆ getUserAspectRatio()

optional< float > kanzi::Node2D::getUserAspectRatio ( ) const
protected

Gets the value of the aspect ratio property assigned to a node.

Aspect ratio of 0 or smaller equals no aspect ratio set.

Returns
optional aspect ratio.

◆ getUserHeight()

optional< float > kanzi::Node2D::getUserHeight ( ) const
protected

Gets the value of the layout height property assigned to a node.

Having an offscreen render target overrides the default size of a node.

Sizes smaller than 0 are clamped to 0.

Returns
Optional height.

◆ getUserWidth()

optional< float > kanzi::Node2D::getUserWidth ( ) const
protected

Gets the value of the layout width property assigned to a node.

Having an offscreen render target overrides the default size of a node.

Sizes smaller than 0 are clamped to 0.

Returns
Optional width.

◆ getDesiredSizeAxisAlignedBoundingBoxMinimum()

Vector2 kanzi::Node2D::getDesiredSizeAxisAlignedBoundingBoxMinimum ( ) const
inlineprotected

Gets the desired size axis aligned bounding box minimum.

Returns
Desired size minimum.

◆ setDesiredSizeAxisAlignedBoundingBoxMinimum() [1/2]

void kanzi::Node2D::setDesiredSizeAxisAlignedBoundingBoxMinimum ( Vector2 size)
inlineprotected

Sets the desired size axis aligned bounding box minimum.

Parameters
sizeNew size vector.

◆ setDesiredSizeAxisAlignedBoundingBoxMinimum() [2/2]

void kanzi::Node2D::setDesiredSizeAxisAlignedBoundingBoxMinimum ( float sizeX,
float sizeY )
inlineprotected

Sets the desired size axis aligned bounding box minimum.

Parameters
sizeXNew desired minimum size X component.
sizeYNew desired minimum size Y component.

◆ getDesiredSizeAxisAlignedBoundingBoxMaximum()

Vector2 kanzi::Node2D::getDesiredSizeAxisAlignedBoundingBoxMaximum ( ) const
inlineprotected

Gets the desired size axis aligned bounding box maximum.

Returns
Desired size maximum.

◆ setDesiredSizeAxisAlignedBoundingBoxMaximum() [1/2]

void kanzi::Node2D::setDesiredSizeAxisAlignedBoundingBoxMaximum ( Vector2 size)
inlineprotected

Sets the desired size axis aligned bounding box maximum.

Parameters
sizeNew size vector.

◆ setDesiredSizeAxisAlignedBoundingBoxMaximum() [2/2]

void kanzi::Node2D::setDesiredSizeAxisAlignedBoundingBoxMaximum ( float sizeX,
float sizeY )
inlineprotected

Sets the desired size maximum.

Parameters
sizeXNew desired maximum size X component.
sizeYNew desired maximum size Y component.

◆ calculateTransformedBoundingArea()

void kanzi::Node2D::calculateTransformedBoundingArea ( const Matrix3x3 & transform,
Vector2 sizeIn )
protected

Calculates new transformed bounding area.

Parameters
transformMatrix to use for calculation.
sizeInInput size.

◆ updateFinalTransform()

void kanzi::Node2D::updateFinalTransform ( const Matrix3x3 & worldTransform,
const Matrix3x3 & parentTransform )
protected

Updates the transformation status based on node properties and calculations in measure and arrange phases.

Called from within updateRender() if necessary (if transform has changed). Kanzi stores all calculated transforms into node fields.

Parameters
worldTransformTransformation in world space.
parentTransformParent's transformation in its composition space.

◆ updateRender()

bool kanzi::Node2D::updateRender ( const Matrix3x3 & worldTransform,
const Matrix3x3 & parentTransform,
bool transformChanged )
protected

Validates a node for rendering.

This is the final part of layouting. (Re)Calculate transformation components, decide whether to render to a framebuffer object, and so on.

Kanzi recalculates transformations only if the transform of the node or its parent changed.

Parameters
worldTransformTransformation in world space.
parentTransformTransformation in parent space.
transformChangedIndicates whether the transform of the node or its parent changed and needs updating.
Returns
If there are additional reasons detected during transform to propagate the transformation process downward, true, otherwise false.

◆ updateRenderOverride()

virtual void kanzi::Node2D::updateRenderOverride ( )
protectedvirtual

Node-specific updates done before render.

Reimplemented in kanzi::Image2D, kanzi::ProgressiveRenderingViewport2D, kanzi::Viewport2D, kanzi::TextBlock2D, and kanzi::TextBox2D.

◆ calculateContentStretch()

optional< QuadDescription > kanzi::Node2D::calculateContentStretch ( Vector2 renderSize,
Vector2 contentSize )
protected

Calculates content stretch.

Parameters
renderSizeRendering area size.
contentSizeSize of content rendered to rendering area.
Returns
Optional foreground quad, if it is relevant.

◆ calculateClippingArea()

ClippingArea kanzi::Node2D::calculateClippingArea ( const Matrix3x3 & parentSpaceTransform) const
protected

Calculates clipping parameters.

Returns
New clipping parameters.

◆ performClipping()

unsigned int kanzi::Node2D::performClipping ( QuadDescription & backgroundQuad,
optional< QuadDescription > & foregroundQuad,
optional< QuadDescription > & effectQuad,
unsigned int clippingResult )
protected

Performs rectangle clipping.

Parameters
backgroundQuadBackground quad, modified in-place.
foregroundQuadOptional foreground quad, modified in-place.
effectQuadOptional effect quad, modified in-place.
clippingResultCurrent clipping result mask.
Returns
Clipping mask.

◆ onTransform()

virtual void kanzi::Node2D::onTransform ( )
protectedvirtual

Node2D transform function.

Since
3.9.4

Reimplemented in kanzi::Viewport2D.

◆ onAttached()

void kanzi::Node2D::onAttached ( )
overrideprotectedvirtual

◆ onDetached()

◆ onNodePropertyChanged()

◆ restoreResources()

void kanzi::Node2D::restoreResources ( )
overrideprotectedvirtual

Node::restoreResources() implementation.

Reimplemented from kanzi::Node.

Reimplemented in kanzi::ProgressiveRenderingViewport2D, and kanzi::Viewport2D.

◆ isEmptyActualSize()

bool kanzi::Node2D::isEmptyActualSize ( ) const
inlineprotected

Returns whether the size of the node is empty or invalid.

Node must have positive size, greater than zero on both axes to be considered having a non-empty size.

Having empty size prevents rendering of node itself but not of its children.

◆ isForegroundHintOpaque()

bool kanzi::Node2D::isForegroundHintOpaque ( ) const
inlineprotected

Indicates whether foreground hint is opaque.

Returns
If foreground hint is opaque, true, otherwise false.

◆ isForegroundHintTranslucent()

bool kanzi::Node2D::isForegroundHintTranslucent ( ) const
inlineprotected

Indicates whether foreground hint is translucent.

Returns
If foreground hint is translucent, true, otherwise false.

◆ setPartialArrangeTransform()

void kanzi::Node2D::setPartialArrangeTransform ( Matrix3x3 transform)
inlineprotected

Sets partial arrange transform.

If the transform has changed, invalidates final transformation.

Parameters
transformThe partial arrange transform to set.

◆ setRenderChildrenAllowed()

void kanzi::Node2D::setRenderChildrenAllowed ( bool enabled)
inlineprotected

Turn render children on or off.

Parameters
enabledTrue to turn on, false to turn off.

◆ setRenderSelfAllowed()

void kanzi::Node2D::setRenderSelfAllowed ( bool enabled)
inlineprotected

Turn render self on or off.

Parameters
enabledTrue to turn on, false to turn off.

◆ setRenderType()

void kanzi::Node2D::setRenderType ( RenderType renderType)
inlineprotected

Set render type.

Parameters
renderTypeRender type.

◆ updateContentTexture()

void kanzi::Node2D::updateContentTexture ( TextureSharedPtr texture)
inlineprotected

Update content texture for the foreground brush.

◆ setSecondPassDesiredSize()

void kanzi::Node2D::setSecondPassDesiredSize ( Vector2 size)
inlineprotected

Set second pass desired size.

Parameters
sizeNew size vector.

◆ calculatePerspectiveTransformMatrices()

bool kanzi::Node2D::calculatePerspectiveTransformMatrices ( int viewportWidth,
int viewportHeight,
Matrix4x4 & cameraMatrix,
Matrix4x4 & projectionMatrix ) const
inlineprotected

Calculate perspective transform matrices.

This is a testing support function and should not be used by user code.

Returns
true if a perspective transform exists. In this case the cameraMatrix and projectionMatrix arguments are set to the final matrices based on the specified viewport size.

◆ setEffect()

void kanzi::Node2D::setEffect ( NodeEffect2DSharedPtr value)
inlineprotected

Sets the value of EffectProperty.

Since
Kanzi 3.9.0

Friends And Related Symbol Documentation

◆ Screen

◆ Viewport3D

◆ doListBoxArrange

void doListBoxArrange ( Node2D & node)
friend

Member Data Documentation

◆ AspectRatioProperty

PropertyType<float> kanzi::Node2D::AspectRatioProperty
static

AspectRatio property.

The default value is 1.0f.

See also
setAspectRatio(), getAspectRatio()

◆ ForceCompositionProperty

PropertyType<bool> kanzi::Node2D::ForceCompositionProperty
static

ForceComposition property.

The default value is false.

See also
setForceComposition(), isForceComposition()

◆ ForegroundHintProperty

PropertyType<Node2D::ForegroundHint> kanzi::Node2D::ForegroundHintProperty
static

ForegroundHint property.

The default value is Node2D::ForegroundHintNone.

See also
setForegroundHint(), getForegroundHint()

◆ OffscreenRenderingProperty

PropertyType<bool> kanzi::Node2D::OffscreenRenderingProperty
static

OffscreenRendering property.

The default value is false.

See also
setOffscreenRendering(), isOffscreenRendering()

◆ DisableRenderTargetClearProperty

PropertyType<bool> kanzi::Node2D::DisableRenderTargetClearProperty
static

DisableRenderTargetClear property.

The default value is false.

See also
setDisableRenderTargetClear(), isDisableRenderTargetClear()

◆ PixelFormatProperty

PropertyType<Node2D::PixelFormat> kanzi::Node2D::PixelFormatProperty
static

PixelFormat property.

The default value is Node2D::PixelFormatRgb.

See also
setPixelFormat(), getPixelFormat()

◆ RenderSelfProperty

PropertyType<bool> kanzi::Node2D::RenderSelfProperty
static

RenderSelf property.

The default value is true.

See also
setRenderSelf(), isRenderSelf()

◆ RenderTargetProperty

PropertyType<ResourceSharedPtr> kanzi::Node2D::RenderTargetProperty
static

RenderTarget property.

The default value is ResourceSharedPtr().

See also
setRenderTarget(), getRenderTarget()

◆ RenderTargetMinimumHeightProperty

PropertyType<float> kanzi::Node2D::RenderTargetMinimumHeightProperty
static

RenderTargetMinimumHeight property.

The default value is 1.0f.

See also
setRenderTargetMinimumHeight(), getRenderTargetMinimumHeight()

◆ RenderTargetMinimumWidthProperty

PropertyType<float> kanzi::Node2D::RenderTargetMinimumWidthProperty
static

RenderTargetMinimumWidth property.

The default value is 1.0f.

See also
setRenderTargetMinimumWidth(), getRenderTargetMinimumWidth()

◆ RenderTargetReallocationLimitProperty

PropertyType<float> kanzi::Node2D::RenderTargetReallocationLimitProperty
static

RenderTargetReallocationLimit property.

The default value is 0.25f.

See also
setRenderTargetReallocationLimit(), getRenderTargetReallocationLimit()

◆ CachingModeProperty

PropertyType<CachingMode> kanzi::Node2D::CachingModeProperty
static

Sets the caching mode:

  • CachingModeDisabled disables caching and sets Kanzi to render the node and its descendants normally.
  • CachingModeEnabled enables caching and sets Kanzi to use the cache until you invalidate it.
  • CachingModeAutomatic sets Kanzi to automatically update the cache of the node whenever the content of the node or its descendants change.
Since
Kanzi 3.9.0

◆ CacheValidProperty

PropertyType<bool> kanzi::Node2D::CacheValidProperty
static

Kanzi sets the value of this property to indicate whether the node is cached.

To disable the cache for one frame, set this property to false. The default value is false.

See also
setCacheValid(), isCacheValid()
Since
Kanzi 3.9.0

◆ LayoutTransformationProperty

PropertyType<SRTValue2D> kanzi::Node2D::LayoutTransformationProperty
static

Sets the layout transformation of the node.

The default value is SRT(Vector2(1.0f, 1.0f), 0.0f, Vector2(0.0f, 0.0f)).

See also
setLayoutTransformation(), getLayoutTransformation()

◆ RenderTransformationProperty

PropertyType<SRTValue2D> kanzi::Node2D::RenderTransformationProperty
static

Sets the render transformation of the node.

The default value is SRT(Vector2(1.0f, 1.0f), 0.0f, Vector2(0.0f, 0.0f)).

See also
setRenderTransformation(), getRenderTransformation()

◆ PerspectiveTransformationProperty

PropertyType<SRTValue3D> kanzi::Node2D::PerspectiveTransformationProperty
static

Sets the perspective transformation of the node.

The default value is identity.

See also
setPerspectiveTransformation, getPerspectiveTransformation

◆ PerspectiveTransformationModeProperty

PropertyType<PerspectiveTransformationMode> kanzi::Node2D::PerspectiveTransformationModeProperty
static

Sets the perspective transformation mode of the node.

The default value is Screen.

See also
setPerspectiveTransformationMode, getPerspectiveTransformationMode

◆ PerspectiveTransformationFovProperty

PropertyType<float> kanzi::Node2D::PerspectiveTransformationFovProperty
static

PerspectiveTransformationFov property.

The default value is 45.

See also
setPerspectiveTransformationFov, getPerspectiveTransformationFov

◆ PerspectiveTransformationPivotProperty

PropertyType<Vector3> kanzi::Node2D::PerspectiveTransformationPivotProperty
static

PerspectiveTransformationOrigin property.

The default value is 0.0,0.0,0.0.

See also
setPerspectiveTransformationPivot, getPerspectiveTransformationPivot

◆ PerspectiveTransformationOriginProperty

PropertyType<Vector3> kanzi::Node2D::PerspectiveTransformationOriginProperty
static

PerspectiveTransformationOrigin property.

The default value is 0.0,0.0,0.0.

See also
setPerspectiveTransformationOrigin, getPerspectiveTransformationOrigin

◆ RenderTransformationOriginProperty

PropertyType<Vector2> kanzi::Node2D::RenderTransformationOriginProperty
static

RenderTransformationOrigin property.

The default value is Vector2(0.0f, 0.0f).

See also
setRenderTransformationOrigin(), getRenderTransformationOrigin()

◆ SnapToPixelProperty

PropertyType<bool> kanzi::Node2D::SnapToPixelProperty
static

SnapToPixel property.

The default value is false.

See also
setSnapToPixel(), isSnapToPixel()

◆ BackgroundBrushProperty

PropertyType<ResourceSharedPtr> kanzi::Node2D::BackgroundBrushProperty
static

BackgroundBrush property.

The default value is ResourceSharedPtr().

See also
setBackgroundBrush(), getBackgroundBrush()

◆ CompositionBrushProperty

PropertyType<ResourceSharedPtr> kanzi::Node2D::CompositionBrushProperty
static

◆ ForegroundBrushProperty

PropertyType<ResourceSharedPtr> kanzi::Node2D::ForegroundBrushProperty
static

ForegroundBrush property.

The default value is ResourceSharedPtr().

See also
setForegroundBrush(), getForegroundBrush()

◆ EffectProperty

PropertyType<ResourceSharedPtr> kanzi::Node2D::EffectProperty
static

Reports the runtime effect instance used by the node, instantiated from the NodeEffectPrefab2D.

Kanzi sets this property internally whenever the value of the EffectPrefabProperty changes. The default value is ResourceSharedPtr()

See also
setEffect(), getEffect()
Since
Kanzi 3.9.0

◆ EffectPrefabProperty

PropertyType<ResourceSharedPtr> kanzi::Node2D::EffectPrefabProperty
static

Sets the 2D Effect prefab to use for the node.

The default value is ResourceSharedPtr()

See also
setEffectPrefab(), getEffectPrefab()
Since
Kanzi 3.9.0

◆ MultisampleLevelProperty

PropertyType<MultisampleCount> kanzi::Node2D::MultisampleLevelProperty
static

Sets the number of anti-aliasing samples to use for temporary composition targets.

The default value is NoMSAA.

See also
setMultisampleLevel(), getMultisampleLevel()
Since
Kanzi 3.9.7

◆ m_visual

unique_ptr<NodeVisual2D> kanzi::Node2D::m_visual
protected

Visual information.

◆ m_compositor

unique_ptr<NodeCompositor2D> kanzi::Node2D::m_compositor
protected

Composition and caching information.

◆ m_backgroundQuadDescription

QuadDescription kanzi::Node2D::m_backgroundQuadDescription
protected

Background clipping quad / composition quad description.

◆ m_effectQuadDescription

optional<QuadDescription> kanzi::Node2D::m_effectQuadDescription
protected

Effect quad description.

◆ m_cachedEffect

NodeEffect2DSharedPtr kanzi::Node2D::m_cachedEffect
protected

Cached effect instance.

◆ m_validatedEffectPaddingChangeCounter

unsigned int kanzi::Node2D::m_validatedEffectPaddingChangeCounter
protected

Effect padding change counter value at which effect quad was last validated.

◆ m_clipping

ClippingArea kanzi::Node2D::m_clipping
protected

Clipping parameters.

◆ m_compositionRequirements

CompositionRequirements kanzi::Node2D::m_compositionRequirements
protected

Composition requirements for this 2D node.

◆ m_currentEffectPrefab

NodeEffectPrefab2DSharedPtr kanzi::Node2D::m_currentEffectPrefab
protected

Currently instantiated effect prefab.


The documentation for this class was generated from the following file: